Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Fragments #638

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft

WIP: Fragments #638

wants to merge 14 commits into from

Conversation

simonw
Copy link
Owner

@simonw simonw commented Nov 18, 2024

Refs:

TODO:

  • Make aliases such as llm prompt -f alias work
  • Document how to use -f option
  • llm fragments list needs non-JSON output (that truncates)
  • Documentation for the llm fragments family of commands
  • Does this need documentation in the Python docs?
  • Fix the problem where prompt_json still duplicates the prompt
  • Comprehensive tests
  • Update llm logs to handle this new mechanism
  • Add this to llm chat - so you can do llm chat -f docs
  • Consider if this should be added to templates (maybe not?)

@simonw simonw added the enhancement New feature or request label Nov 18, 2024
@simonw
Copy link
Owner Author

simonw commented Nov 18, 2024

Here's a but of a weird problem. We're storing fragments in the logs.db database - but that means this logic here isn't quite right:

llm/llm/cli.py

Lines 476 to 482 in 9b2d4d6

# Log to the database
if (logs_on() or log) and not no_log and not async_:
log_path = logs_db_path()
(log_path.parent).mkdir(parents=True, exist_ok=True)
db = sqlite_utils.Database(log_path)
migrate(db)
response.log_to_db(db)

Here we are only even creating that logs.db database at the very end of prompt() if the user has logging enabled.

But now we need that database at the start of that CLI command in case we need to resolve any fragment aliases using it.

It's a bit weird that it's called logs.db now that it's supporting an additional feature that's not related to if logs are turned on or not. I think I can live with that though.

@simonw
Copy link
Owner Author

simonw commented Nov 18, 2024

Lots more fragments available now - I added Datasette, sqlite-utils, s3-credentials and shot-scraper docs to https://github.com/simonw/llm-docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant