Query databases and tables with AI assistance
Early alpha.
Install this plugin in the same environment as Datasette.
datasette install datasette-query-assistantSet the model ID to be used by this plugin by adding this to your Datasette configuration:
plugins:
datasette-query-assistant:
model: openai/gpt-4.1-mini
key_env_var: OPENAI_API_KEYTo use the openai/gpt-4.1-mini model you'll need to install llm-openai-plugin in addition to datasette-query-assistant.
If the model needs an API key, set the key_env_var to the name of an environment variable and ensure that environment variable is correctly set.
You can use any model that is available via an LLM plugin
Users with execute-sql permission will gain a database action menu item for "Query this database with AI assistance" which will let them ask a question and be redirected to a commented SQL query that will hopefully answer it.
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-query-assistant
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:
pip install -e '.[test]'To run the tests:
pytestTo re-generate the tests with refreshed examples from the API:
pytest -x --record-mode=rewrite --inline-snapshot=fix