Texera / texera

Collaborative Machine-Learning-Centric Data Analytics Using Workflows
https://texera.github.io
Apache License 2.0
161 stars 68 forks source link

[3/3] Add AI Assistant Service - add the "Add All Type Annotation" Python UDF action #2812

Open IamtherealBrian opened 2 weeks ago

IamtherealBrian commented 2 weeks ago

This PR introduces another AI feature call "Add All Type Annotation" that enhance the user experience of the Python UDF after integrating with the Pyright language server. You can refer to the related PR here: -PR for the "Add the pyright language server" : https://github.com/Texera/texera/pull/2797. -PR for the "[1/3] Add AI Assistant Service - Ai Flag" : https://github.com/Texera/texera/pull/2808 -PR for the "[2/3] Add AI Assistant Service - add the "Add Type Annotation" Python UDF action" : https://github.com/Texera/texera/pull/2811

Key change: Added another Monaco action in the frontend Python UDF editor to allow users to automatically add all type annotations for the arguments within their selected code block.

Add All Type Annotation: This action requires the user to select a code block in their Python UDF code. The action will automatically identify all arguments without type annotations and provide type annotation suggestions for each argument sequentially. The selected code block will be sent to the backend for Python Abstract Syntax Tree (AST) analysis to locate arguments without type annotations, and the result will be sent back to the frontend via a RESTful API. If the user selects a code block that has no arguments or where all the arguments already have type annotations, the code will remain unchanged. Example:

https://github.com/user-attachments/assets/d70c1b02-b309-4359-a267-0a5eef831316