datasette-query-assistant by datasette

122 downloads this week        Star

README source code

datasette-query-assistant

PyPI Changelog Tests License

Query databases and tables with AI assistance

Early alpha.

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-query-assistant

Configuration

This plugin currently requires you to set the ANTHROPIC_API_KEY environment variable to a working Anthropic API key.

Usage

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 SQL that will hopefully answer it.

Development

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/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

To re-generate the tests with refreshed examples from the Claude 3 API:

pytest -x --record-mode=rewrite --inline-snapshot=fix