From 13fd67d62a38d8a6a8cf2f042a459acc2038b3b0 Mon Sep 17 00:00:00 2001 From: Chris Clark Date: Tue, 9 Apr 2024 10:07:55 -0400 Subject: [PATCH] Sql assistant (#569) * LLM-powered SQL Assistant --- HISTORY.rst | 2 + docs/features.rst | 11 +- docs/install.rst | 32 +++++ explorer/__init__.py | 6 +- explorer/app_settings.py | 9 ++ explorer/assistant/__init__.py | 0 explorer/assistant/models.py | 21 +++ explorer/assistant/prompts.py | 11 ++ explorer/assistant/tests.py | 90 +++++++++++++ explorer/assistant/utils.py | 97 ++++++++++++++ explorer/assistant/views.py | 87 ++++++++++++ explorer/migrations/0014_promptlog.py | 29 ++++ explorer/src/js/assistant.js | 149 +++++++++++++++++++++ explorer/src/js/explorer.js | 14 +- explorer/src/js/main.js | 11 +- explorer/src/scss/assistant.scss | 35 +++++ explorer/src/scss/explorer.scss | 12 +- explorer/src/scss/styles.scss | 2 +- explorer/templates/explorer/assistant.html | 49 +++++++ explorer/templates/explorer/play.html | 3 + explorer/templates/explorer/query.html | 3 + explorer/tests/settings.py | 1 + explorer/tracker.py | 4 +- explorer/urls.py | 2 + explorer/views/mixins.py | 1 + package-lock.json | 18 +++ package.json | 4 +- requirements/base.txt | 1 + requirements/optional.txt | 2 + test_project/settings.py | 2 + 30 files changed, 687 insertions(+), 21 deletions(-) create mode 100644 explorer/assistant/__init__.py create mode 100644 explorer/assistant/models.py create mode 100644 explorer/assistant/prompts.py create mode 100644 explorer/assistant/tests.py create mode 100644 explorer/assistant/utils.py create mode 100644 explorer/assistant/views.py create mode 100644 explorer/migrations/0014_promptlog.py create mode 100644 explorer/src/js/assistant.js create mode 100644 explorer/src/scss/assistant.scss create mode 100644 explorer/templates/explorer/assistant.html diff --git a/HISTORY.rst b/HISTORY.rst index d8197a76..444d7367 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -7,6 +7,8 @@ This project adheres to `Semantic Versioning `_. `4.1.0`_ (TBD) =========================== +* SQL Assistant: Built in query help via OpenAI (or LLM of choice), with relevant schema + automatically injected into the prompt. Enable via setting EXPLORER_AI_API_KEY. * Anonymous usage telemetry. Can be disabled by setting EXPLORER_ENABLE_ANONYMOUS_STATS to False * `#594`_: Eliminate