Skip to content

Conversation

@IamtherealBrian
Copy link
Contributor

@IamtherealBrian IamtherealBrian commented Aug 29, 2024

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

@IamtherealBrian IamtherealBrian requested a review from yunyad August 29, 2024 21:51
@IamtherealBrian IamtherealBrian self-assigned this Aug 29, 2024
@IamtherealBrian IamtherealBrian changed the title [2/3] Add AI Assistant Service - add the first Python UDF action [2/3] Add AI Assistant Service - add the “Add Type Annotation" Python UDF action Aug 31, 2024
IamtherealBrian added a commit that referenced this pull request Sep 2, 2024
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>
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

@chenlica chenlica left a 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.

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.

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

IamtherealBrian and others added 5 commits September 3, 2024 13:22
…#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>
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. The frontend would require major changes.

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.

LGTM. Left minor comments.

@IamtherealBrian IamtherealBrian merged commit a892766 into master Sep 20, 2024
@IamtherealBrian IamtherealBrian deleted the minchongWu-aiFeatures1-pr branch September 20, 2024 18:26
IamtherealBrian added a commit that referenced this pull request Oct 2, 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
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
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>
PurelyBlank pushed a commit that referenced this pull request Dec 4, 2024
… 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>
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
@Yicong-Huang Yicong-Huang added frontend Changes related to the frontend GUI and removed gui labels Jul 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants