From 81f15fb1f9631f0768d08d64b0286e24e454cf62 Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Thu, 29 Aug 2024 09:34:31 -0400 Subject: [PATCH] assistant history --- HISTORY.rst | 1 + explorer/assistant/forms.py | 2 +- explorer/src/js/assistant.js | 14 +- explorer/src/js/explorer.js | 2 +- explorer/src/js/tableDescription.js | 7 + explorer/src/scss/assistant.scss | 12 + explorer/src/scss/choices.scss | 323 ++++++++++++++++++ explorer/src/scss/styles.scss | 3 +- explorer/src/scss/variables.scss | 1 + .../assistant/table_description_form.html | 71 ++-- explorer/templates/explorer/assistant.html | 15 +- explorer/tests/test_assistant.py | 134 ++++++++ 12 files changed, 539 insertions(+), 46 deletions(-) create mode 100644 explorer/src/scss/choices.scss diff --git a/HISTORY.rst b/HISTORY.rst index 7f2b7f31..764b602d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -21,6 +21,7 @@ vNext - Relevant tables are added client-side visually, in real time, based on what's in the SQL editor and/or any tables mentioned in the assistant request. The dependency on sql_metadata is therefore removed, as server-side SQL parsing is no longer necessary. + - Ability to view Assistant request/response history. - Improved system prompt that emphasizes the particular SQL dialect being used. - Addresses issue #657. diff --git a/explorer/assistant/forms.py b/explorer/assistant/forms.py index f4c69780..ddcaffea 100644 --- a/explorer/assistant/forms.py +++ b/explorer/assistant/forms.py @@ -25,7 +25,7 @@ def __init__(self, *args, **kwargs): f = forms.ChoiceField( choices=choices, - widget=forms.Select(attrs={"class": "form-select"}) + 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. diff --git a/explorer/src/js/assistant.js b/explorer/src/js/assistant.js index eb052c3c..8e7ce159 100644 --- a/explorer/src/js/assistant.js +++ b/explorer/src/js/assistant.js @@ -46,8 +46,6 @@ function setupTableList() { removeItemButton: true, searchEnabled: true, shouldSort: false, - placeholder: true, - placeholderValue: 'Relevant tables', position: 'bottom' }); @@ -132,8 +130,10 @@ export function setUpAssistant(expand = false) { function getAssistantHistory() { + const historyModalId = 'historyModal'; + // Remove any existing modal with the same ID - const existingModal = document.getElementById('historyModal'); + const existingModal = document.getElementById(historyModalId); if (existingModal) { existingModal.remove() } @@ -186,7 +186,7 @@ function getAssistantHistory() { // Insert the table into a new Bootstrap modal const modalHtml = ` -