Skip to content

Instantly share code, notes, and snippets.

@simonw
Created July 10, 2023 17:59
Show Gist options
  • Select an option

  • Save simonw/bcf067c1fc93c508591be3ab3e248246 to your computer and use it in GitHub Desktop.

Select an option

Save simonw/bcf067c1fc93c508591be3ab3e248246 to your computer and use it in GitHub Desktop.
datasette-llm plugin prototype - adds a "datasette llm" command to Datasette which mirrors the "llm" command from LLM.
from datasette import hookimpl
from llm.cli import cli as llm_cli
@hookimpl
def register_commands(cli):
cli.add_command(llm_cli, name="llm")
[project]
name = "datasette-llm"
version = "0.1"
dependencies = [
"datasette",
"llm",
]
[project.entry-points.datasette]
llm = "datasette_llm"
@simonw

simonw commented Jul 10, 2023

Copy link
Copy Markdown
Author

With this installed:

datasette --help
Usage: datasette [OPTIONS] COMMAND [ARGS]...

  Datasette is an open source multi-tool for exploring and publishing data

  About Datasette: https://datasette.io/
  Full documentation: https://docs.datasette.io/

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  serve*        Serve up specified SQLite database files with a web UI
  create-token  Create a signed API token for the specified actor ID
  inspect       Generate JSON summary of provided database files
  install       Install plugins and packages from PyPI into the same...
  llm           Access large language models from the command-line
  package       Package SQLite files into a Datasette Docker container
  plugins       List currently installed plugins
  publish       Publish specified SQLite database files to the internet...
  uninstall     Uninstall plugins and Python packages from the Datasette...

And:

datasette llm 'five names for a happy penguin'
1. Sunny
2. Joy
3. Bounce
4. Pippin
5. Cheer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment