Skip to content

Conversation

@IamtherealBrian
Copy link
Contributor

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:

add.all.type.annotation.mp4

@IamtherealBrian IamtherealBrian self-assigned this Sep 21, 2024
Copy link
Contributor

@Yicong-Huang Yicong-Huang left a 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 for changes. The major ones are:

  1. the way you generate annotations, should use AST to generate, not text-based (i.e., start line/col or end line/col).
  2. you do need to test cases to validate the functionality of your type annotate module. I could not review it by just looking at the code. Also I doubt it works with complex cases such as a static method with keyward arguments and wildcard arguments.
  3. frontend logic seems unnatural to me. maybe you are not following the typical MVVC design?

Copy link
Contributor

@Yicong-Huang Yicong-Huang left a comment

Choose a reason for hiding this comment

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

In general looks good! Left some comments to handle.

@IamtherealBrian IamtherealBrian merged commit f6bd7c4 into master Oct 2, 2024
@IamtherealBrian IamtherealBrian deleted the minchongWu-ai-feature2-new branch October 2, 2024 19:32
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
…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
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