-
Notifications
You must be signed in to change notification settings - Fork 113
[2/3] Add AI Assistant Service - add the “Add Type Annotation" Python UDF action #2811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is the first PR of the "Add AI Assistant Service" series, which will consist of 3 PRs in total. -PR for the "[2/3] Add AI Assistant Service - add the "Add Type Annotation" Python UDF action" : #2811 -PR for the "[3/3] Add AI Assistant Service - add the "Add All Type Annotation" Python UDF action" : #2812 This PR introduces an AI Assistant flag that allows users to switch between "none" (disabling the AI assistant) and "openai" (using OpenAI as the AI assistant). If the 'none' flag is selected, all AI features will be hidden and unavailable to the user. If the 'openai' flag is selected, AI features will be enabled and accessible in the Python UDF editor. (The implementation of these AI features will be covered in PR2 of 3 and PR3 of 3). **Key idea of each new file:** (1) AiAssistantManager.scala: Handling results corresponding to the two cases obtained from the flag. (2) AiAssistantResource.scala: Implement three RESTful API endpoints to manage AI flag. **Notice:** Since the AI features are in the second and third PRs, the RESTful API functionality in this PR cannot be tested yet, as it will only be used in the second and third PRs. However, if you just want to test the result, you can print the result of the boolean for the testing purpose by calling the frontend method `checkAiAssistantEnabled()`. --------- Co-authored-by: Xudong Wu <2373025856w@gmail.com>
yunyad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
chenlica
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I revised the description of the PR.
Yicong-Huang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A major comment is that we should push prompt generation to backend. Also frontend logic please use Observables and Subscription to implement as Angular's recommendation. more to read https://stackoverflow.com/questions/37364973/what-is-the-difference-between-promises-and-observables
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantResource.scala
Outdated
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantResource.scala
Outdated
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantResource.scala
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantResource.scala
Outdated
Show resolved
Hide resolved
core/gui/src/app/dashboard/service/user/ai-assistant/ai-assistant.service.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
…#2823) Use `main.ts` which done by `Typefox` to start pyright instead of `startPyright.mjs`. The work done by `Typefox` can be referred to: https://github.com/TypeFox/monaco-languageclient/tree/main/packages/examples/src/python --------- Co-authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com> Co-authored-by: Yicong Huang <yicong.huang@observeinc.com>
240b068 to
2b3e779
Compare
Yicong-Huang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments. The frontend would require major changes.
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantResource.scala
Outdated
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantResource.scala
Outdated
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantResource.scala
Outdated
Show resolved
Hide resolved
core/gui/src/app/dashboard/service/user/ai-assistant/ai-assistant.service.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/dashboard/service/user/ai-assistant/ai-assistant.service.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/dashboard/service/user/ai-assistant/ai-assistant.service.ts
Outdated
Show resolved
Hide resolved
Yicong-Huang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left minor comments.
core/gui/src/app/workspace/component/code-editor-dialog/annotation-suggestion.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/annotation-suggestion.component.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Show resolved
Hide resolved
core/gui/src/app/workspace/component/code-editor-dialog/code-editor.component.ts
Show resolved
Hide resolved
core/gui/src/app/workspace/service/ai-assistant/ai-assistant.service.ts
Outdated
Show resolved
Hide resolved
core/gui/src/app/workspace/service/ai-assistant/ai-assistant.service.ts
Outdated
Show resolved
Hide resolved
…thon UDF action (#2857) 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" : #2797. -PR for the "[1/3] Add AI Assistant Service - Ai Flag" : #2808 -PR for the "[2/3] Add AI Assistant Service - add the "Add Type Annotation" Python UDF action" : #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
This is the first PR of the "Add AI Assistant Service" series, which will consist of 3 PRs in total. -PR for the "[2/3] Add AI Assistant Service - add the "Add Type Annotation" Python UDF action" : #2811 -PR for the "[3/3] Add AI Assistant Service - add the "Add All Type Annotation" Python UDF action" : #2812 This PR introduces an AI Assistant flag that allows users to switch between "none" (disabling the AI assistant) and "openai" (using OpenAI as the AI assistant). If the 'none' flag is selected, all AI features will be hidden and unavailable to the user. If the 'openai' flag is selected, AI features will be enabled and accessible in the Python UDF editor. (The implementation of these AI features will be covered in PR2 of 3 and PR3 of 3). **Key idea of each new file:** (1) AiAssistantManager.scala: Handling results corresponding to the two cases obtained from the flag. (2) AiAssistantResource.scala: Implement three RESTful API endpoints to manage AI flag. **Notice:** Since the AI features are in the second and third PRs, the RESTful API functionality in this PR cannot be tested yet, as it will only be used in the second and third PRs. However, if you just want to test the result, you can print the result of the boolean for the testing purpose by calling the frontend method `checkAiAssistantEnabled()`. --------- Co-authored-by: Xudong Wu <2373025856w@gmail.com>
… UDF action (#2811) This PR introduces a new AI-based feature called "Add Type Annotation" that enhances the user experience of the Python UDF on top of the Pyright language server. The following are related PR's: -PR for the "Add the pyright language server" : #2797. -PR for the "[1/3] Add AI Assistant Service - Ai Flag" : #2808 -PR for the "[3/3] Add AI Assistant Service - add the "Add All Type Annotation" Python UDF action" : #2812 **Key changes:** Added a Monaco action in the frontend Python UDF editor to allow users to automatically add type annotations for an argument each time they select a single argument in their code. **Add Type Annotation:** This action requires the user to select a single argument in their Python UDF code. A UI with a suggestion for the selected argument will pop up. The user can choose to accept or decline the suggestion from OpenAI. If they accept the suggestion, it will be added to their code; otherwise, the code will remain unchanged. The suggestion is provided by OpenAI. After the backend receives the response from OpenAI, it will be forwarded to the frontend via a RESTful API. Example: https://github.com/user-attachments/assets/29cee6c8-c793-4d83-8b27-db64bcc636ae --------- Co-authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com> Co-authored-by: Yicong Huang <yicong.huang@observeinc.com>
…thon UDF action (#2857) 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" : #2797. -PR for the "[1/3] Add AI Assistant Service - Ai Flag" : #2808 -PR for the "[2/3] Add AI Assistant Service - add the "Add Type Annotation" Python UDF action" : #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
This PR introduces a new AI-based feature called "Add Type Annotation" that enhances the user experience of the Python UDF on top of the Pyright language server. The following are related PR's:
-PR for the "Add the pyright language server" : #2797.
-PR for the "[1/3] Add AI Assistant Service - Ai Flag" : #2808
-PR for the "[3/3] Add AI Assistant Service - add the "Add All Type Annotation" Python UDF action" : #2812
Key changes:
Added a Monaco action in the frontend Python UDF editor to allow users to automatically add type annotations for an argument each time they select a single argument in their code.
Add Type Annotation:
This action requires the user to select a single argument in their Python UDF code. A UI with a suggestion for the selected argument will pop up. The user can choose to accept or decline the suggestion from OpenAI. If they accept the suggestion, it will be added to their code; otherwise, the code will remain unchanged. The suggestion is provided by OpenAI. After the backend receives the response from OpenAI, it will be forwarded to the frontend via a RESTful API.
Example:
7879e394439dc30d2e09baaf36062bf1.mp4