-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Assistant improvements: Table annotations, and few-shot examples (#664)
* Table annotations * Few-shot prompt examples * View Assistant history * Better 'relevant table' detection and UI * Improved prompts * Cmd+shift+F shortcut for formatting SQL
- Loading branch information
1 parent
84c2eef
commit 2d7736d
Showing
43 changed files
with
1,532 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from django import forms | ||
from explorer.assistant.models import TableDescription | ||
from explorer.ee.db_connections.utils import default_db_connection | ||
|
||
|
||
class TableDescriptionForm(forms.ModelForm): | ||
class Meta: | ||
model = TableDescription | ||
fields = "__all__" | ||
widgets = { | ||
"database_connection": forms.Select(attrs={"class": "form-select"}), | ||
"description": forms.Textarea(attrs={"class": "form-control", "rows": 3}), | ||
} | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
if not self.instance.pk: # Check if this is a new instance | ||
# Set the default value for database_connection | ||
self.fields["database_connection"].initial = default_db_connection() | ||
|
||
if self.instance and self.instance.table_name: | ||
choices = [(self.instance.table_name, self.instance.table_name)] | ||
else: | ||
choices = [] | ||
|
||
f = forms.ChoiceField( | ||
choices=choices, | ||
widget=forms.Select(attrs={"class": "form-select", "data-placeholder": "Select table"}) | ||
) | ||
|
||
# We don't actually care about validating the 'choices' that the ChoiceField does by default. | ||
# Really we are just using that field type in order to get a valid pre-populated Select widget on the client | ||
# But also it can't be blank! | ||
def valid_value_new(v): | ||
return bool(v) | ||
|
||
f.valid_value = valid_value_new | ||
|
||
self.fields["table_name"] = f | ||
|
||
if self.instance and self.instance.table_name: | ||
self.fields["table_name"].initial = self.instance.table_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.urls import path | ||
from explorer.assistant.views import (TableDescriptionListView, | ||
TableDescriptionCreateView, | ||
TableDescriptionUpdateView, | ||
TableDescriptionDeleteView, | ||
AssistantHelpView, | ||
AssistantHistoryApiView) | ||
|
||
assistant_urls = [ | ||
path("assistant/", AssistantHelpView.as_view(), name="assistant"), | ||
path("assistant/history/", AssistantHistoryApiView.as_view(), name="assistant_history"), | ||
path("table-descriptions/", TableDescriptionListView.as_view(), name="table_description_list"), | ||
path("table-descriptions/new/", TableDescriptionCreateView.as_view(), name="table_description_create"), | ||
path("table-descriptions/<int:pk>/update/", TableDescriptionUpdateView.as_view(), name="table_description_update"), | ||
path("table-descriptions/<int:pk>/delete/", TableDescriptionDeleteView.as_view(), name="table_description_delete"), | ||
] |
Oops, something went wrong.