-
Notifications
You must be signed in to change notification settings - Fork 113
[1/3] Add AI Assistant Service - AI Flag #2808
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
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantResource.scala
Outdated
Show resolved
Hide resolved
...er/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/python_abstract_syntax_tree.py
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/AiAssistantManager.scala
Outdated
Show resolved
Hide resolved
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.
Please check my comments and add the links in the description. Thank you!
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantManager.scala
Outdated
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantManager.scala
Outdated
Show resolved
Hide resolved
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.
2 small issues.
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 please format before merge.
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.
Please check my comments
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantManager.scala
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantManager.scala
Outdated
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantManager.scala
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantManager.scala
Outdated
Show resolved
Hide resolved
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/aiassistant/AiAssistantManager.scala
Show resolved
Hide resolved
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.
Now it looks good after those changes.
) This PR enhances the AI flag by allowing ai-assistant-server to be missing. The previous PR:#2808 **Optional AI Assistant Configuration:** The new version allows the ai-assistant-server configuration to be missing. In this case, its behavior corresponds to the case of "NoAiAssistant".
This PR enhances the report generation functionality by adding animation during the process. This PR is a continuation and enhancement of the previous PR: Adding a button to generate a report for a workflow: #2770 Enhancing Report Generation by adding Operator Results: #2792 Enhancing Report Generation by Adding Operator Json and Comments Section : #2807 Ai Flag: #2818 and #2808 Key Changes: **menu.component.ts:** At the start, notification.blank is called to display a message, and notification.remove is used to remove it at the end. Upon successful generation, this.notificationService.success is invoked. **notification.service.ts:** notification.blank and notification.remove have been added. Screenshot of the notification:  
… 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
#2816) This PR enhances the report generation functionality by addingStory-teller Ai based on Ai flag. This PR is a continuation and enhancement of the previous PR: Adding a button to generate a report for a workflow: #2770 Enhancing Report Generation by adding Operator Results: #2792 Enhancing Report Generation by Adding Operator Json and Comments Section : #2807 Ai Flag: #2818 and #2808 **New Methods:** checkAiAssistantEnabled(): Validates whether the AI Assistant feature is enabled by checking the availability of the required API key. This function ensures that subsequent AI-based functionalities are executed only when the AI Assistant is available. generateComment(operatorInfo: any): Generates insightful comments for each operator using OpenAI’s GPT model, tailored for a highly educated audience but one that might not have deep statistical knowledge. The comments are plain text, enhancing the overall readability and value of the report. generateSummaryComment(operatorInfo: any): Produces a concise, insightful summary comment that highlights key findings, trends, and areas of improvement across the workflow, focusing particularly on UDFs. This function is crucial for providing a comprehensive understanding of the workflow to users. **Enhanced Methods:** retrieveOperatorInfoReport(operatorId: string, allResults: { operatorId: string; html: string }[]): Implements the checkAiAssistantEnabled, generateComment, and generateSummaryComment functions to enrich the operator information section in the generated reports. The function now adds a "Toggle Detail" button beneath each operator, allowing users to expand and view the operator’s corresponding JSON, formatted using a JSON viewer. Additionally, a comments section is added below each operator, enabling users to leave or view AI-generated comments. generateReportAsHtml(workflowSnapshot: string, allResults: string[], workflowName: string): Generates a comprehensive HTML file containing the workflow snapshot, all operator results, operator details, and comments. This method integrates AI-generated comments and a summary section at the end of the report. It also introduces a "Download Workflow JSON" button, allowing users to download the entire workflow JSON file directly from the report. **Operation Process:** Click the button below to generate the report with detailed operator results and the workflow snapshot.  To turn on the ai feature, you need to modify the following sections in application.udf  For example, to turn on the openai:  Here is a part of the example report.  
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>
) This PR enhances the AI flag by allowing ai-assistant-server to be missing. The previous PR:#2808 **Optional AI Assistant Configuration:** The new version allows the ai-assistant-server configuration to be missing. In this case, its behavior corresponds to the case of "NoAiAssistant".
This PR enhances the report generation functionality by adding animation during the process. This PR is a continuation and enhancement of the previous PR: Adding a button to generate a report for a workflow: #2770 Enhancing Report Generation by adding Operator Results: #2792 Enhancing Report Generation by Adding Operator Json and Comments Section : #2807 Ai Flag: #2818 and #2808 Key Changes: **menu.component.ts:** At the start, notification.blank is called to display a message, and notification.remove is used to remove it at the end. Upon successful generation, this.notificationService.success is invoked. **notification.service.ts:** notification.blank and notification.remove have been added. Screenshot of the notification:  
… 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
#2816) This PR enhances the report generation functionality by addingStory-teller Ai based on Ai flag. This PR is a continuation and enhancement of the previous PR: Adding a button to generate a report for a workflow: #2770 Enhancing Report Generation by adding Operator Results: #2792 Enhancing Report Generation by Adding Operator Json and Comments Section : #2807 Ai Flag: #2818 and #2808 **New Methods:** checkAiAssistantEnabled(): Validates whether the AI Assistant feature is enabled by checking the availability of the required API key. This function ensures that subsequent AI-based functionalities are executed only when the AI Assistant is available. generateComment(operatorInfo: any): Generates insightful comments for each operator using OpenAI’s GPT model, tailored for a highly educated audience but one that might not have deep statistical knowledge. The comments are plain text, enhancing the overall readability and value of the report. generateSummaryComment(operatorInfo: any): Produces a concise, insightful summary comment that highlights key findings, trends, and areas of improvement across the workflow, focusing particularly on UDFs. This function is crucial for providing a comprehensive understanding of the workflow to users. **Enhanced Methods:** retrieveOperatorInfoReport(operatorId: string, allResults: { operatorId: string; html: string }[]): Implements the checkAiAssistantEnabled, generateComment, and generateSummaryComment functions to enrich the operator information section in the generated reports. The function now adds a "Toggle Detail" button beneath each operator, allowing users to expand and view the operator’s corresponding JSON, formatted using a JSON viewer. Additionally, a comments section is added below each operator, enabling users to leave or view AI-generated comments. generateReportAsHtml(workflowSnapshot: string, allResults: string[], workflowName: string): Generates a comprehensive HTML file containing the workflow snapshot, all operator results, operator details, and comments. This method integrates AI-generated comments and a summary section at the end of the report. It also introduces a "Download Workflow JSON" button, allowing users to download the entire workflow JSON file directly from the report. **Operation Process:** Click the button below to generate the report with detailed operator results and the workflow snapshot.  To turn on the ai feature, you need to modify the following sections in application.udf  For example, to turn on the openai:  Here is a part of the example report.  
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().