Skip to content
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

Review and update the current state of our AI integration #8348

Closed
jdunkerley opened this issue Nov 21, 2023 · 4 comments
Closed

Review and update the current state of our AI integration #8348

jdunkerley opened this issue Nov 21, 2023 · 4 comments
Assignees
Labels
-ai tasks for adding ChatGPT based suggestions -language-server -libs Libraries: New libraries to be implemented

Comments

@jdunkerley
Copy link
Member

jdunkerley commented Nov 21, 2023

Need to review the work previous done by Marcin and Jan.
Look at what works / doesn't as it stands.

Goal of this ticket is to understand where we currently are and then we can work out a plan to get the functionality back to fully capable.

@jdunkerley jdunkerley added -ci -compiler -libs Libraries: New libraries to be implemented -language-server labels Nov 21, 2023
@jdunkerley jdunkerley added -ai tasks for adding ChatGPT based suggestions and removed -ci -compiler labels Nov 21, 2023
@jdunkerley
Copy link
Member Author

jdunkerley commented Nov 21, 2023

@JaroslavTulach please add references:

@enso-bot
Copy link

enso-bot bot commented Nov 24, 2023

Dmitry Bushev reports a new STANDUP for today (2023-11-24):

Progress: Started working on the task. Obtained an API key. Investigated how the AI completion is enabled in the language server. Investigated how the AI completion is implemented in the IDE. Found out how to open the AI completion prompt. Played with the completion a bit It should be finished by 2023-11-27.

Next Day: Next day I will be working on the #8348 task. Continue working on the task

@4e6
Copy link
Contributor

4e6 commented Nov 24, 2023

How to use

  • The AI completion is enabled by providing the OPENAI_API_KEY environment variable. It is required for the Language server to make calls to openai.
  • The AI completion prompt is toggled by cmd+tab key combination in IDE.
    ⚠️ on Linux, I have to hold the tab key and then press the ctrl button to make the shortcut work. There is an open issue about that Handle conflicting shortcuts in a nicer way. #7528

Implementation

The AI completion is implemented by creating a query from the user prompt and sending it to https://api.openai.com/v1/completions.

To form a query, each user prompt is wrapped in a template describing the table API

ops_prompt = "Operations available on Table are: " + (ops . join ",")
aggs_prompt = "Available ways to aggregate a column are: " + (aggs . join ",")
joins_prompt = "Available join kinds are: " + (joins . join ",")
base_prompt = ops_prompt + '\n' + aggs_prompt + '\n' + joins_prompt + '\n' + examples
columns = self.column_names . map .to_text . join "," "Table[" "];"
goal_line = "goal=" + goal_placeholder + "==>>`"
base_prompt + '\n' + columns + goal_line

and providing examples

Table["id","category","Unit Price","Stock"];goal=get product count by category==>>`aggregate [Aggregate_Column.Group_By "category", Aggregate_Column.Count Nothing]`
Table["ID","Unit Price","Stock"];goal=order by how many items are available==>>`order_by ["Stock"]`
Table["Name","Enrolled Year"];goal=select people who enrolled between 2015 and 2018==>>`filter_by_expression "[Enrolled Year] >= 2015 && [Enrolled Year] <= 2018`
Table["Number of items","client name","city","unit price"];goal=compute the total value of each order==>>`set "[Number of items] * [unit price]" "total value"`
Table["Number of items","client name","CITY","unit price","total value"];goal=compute the average order value by city==>>`aggregate [Aggregate_Column.Group_By "CITY", Aggregate_Column.Average "total value"]`
Table["Area Code", "number"];goal=get full phone numbers==>>`set "'+1 (' + [Area Code] + ') ' + [number]" "full phone number"`
Table["Name","Grade","Subject"];goal=rank students by their average grade==>>`aggregate [Aggregate_Column.Group_By "Name", Aggregate_Column.Average "Grade" "Average Grade"] . order_by [Sort_Column.Name "Average Grade" Sort_Direction.Descending]`
Table["Country","Prime minister name","2018","2019","2020","2021"];goal=pivot yearly GDP values to rows==>>`transpose ["Country", "Prime minister name"] "Year" "GDP"`
Table["Size","Weight","Width","stuff","thing"];goal=only select size and thing of each record==>>`select_columns ["Size", "thing"]`
Table["ID","Name","Count"];goal=join it with var_17==>>`join var_17 Join_Kind.Inner`

The query looks like:

Operations available on Table are: <example code>
Available ways to aggregate a column are: <example code>
...
goal: <user prompt>

Then based on the provided examples, ChatGPT tries to come up with a code sequence that would satisfy the goal.

It works better than I expected given how little information is provided to ChatGPT

enso-ai.mp4

@4e6
Copy link
Contributor

4e6 commented Nov 27, 2023

@4e6 4e6 closed this as completed Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-ai tasks for adding ChatGPT based suggestions -language-server -libs Libraries: New libraries to be implemented
Projects
Archived in project
Development

No branches or pull requests

3 participants