Skip to content

Conversation

@IamtherealBrian
Copy link
Contributor

@IamtherealBrian IamtherealBrian commented Aug 22, 2024

This PR adds a flag to allow the user to use the AI assistant (currently only OpenAI) and introduces some AI features that enhance the user experience of the Python UDF after integrating with the Pyright language server. You can refer to the PR for the Pyright language server here: #2797.

Key change:

  1. Added an AI assistant flag to allow users to switch between "none" (no AI assistant) and "openai" (using OpenAI as the AI assistant).
  2. Added two Monaco actions in the frontend Python UDF editor to allow users to automatically add type annotations to their arguments. The first action is called "Add Type Annotation," and the second action is called "Add All Type Annotations."

Flag:
If the user chooses the 'none' flag, all AI features will be hidden and not available to the user. Otherwise, the AI features will be accessible in the Python UDF editor.

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

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:

add.all.type.annotation.mp4

Summary:
With these two AI features, users can easily add type annotations to their code. This will enable the Pyright language server to perform better at detecting semantic errors after the type annotations are added.

@IamtherealBrian IamtherealBrian requested a review from yunyad August 22, 2024 07:09
@IamtherealBrian IamtherealBrian self-assigned this Aug 22, 2024
Copy link
Contributor

@yunyad yunyad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, please check the comments.

Copy link
Contributor

@yunyad yunyad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@yunyad yunyad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to have a further discussion.

@IamtherealBrian IamtherealBrian changed the title Add AI-Assistant-Server flag Add AI-Assistant flag and features Aug 28, 2024
@IamtherealBrian IamtherealBrian requested a review from yunyad August 29, 2024 01:18
@aglinxinyuan aglinxinyuan deleted the minchongwu-aiflag-pr branch September 6, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants