Skip to content

llm --python-tools CODE option, inspired by sqlite-utils --functions #995

@simonw

Description

@simonw

I'm also going to support a --python-tools option that takes a string of code - similar to how --functions works in sqlite-utils: https://sqlite-utils.datasette.io/en/stable/cli.html#defining-custom-sql-functions

sqlite-utils query sites.db "select url, domain(url) from urls" --functions '
from urllib.parse import urlparse

def domain(url):
    return urlparse(url).netloc
'

Any Python function without a _ prefix will be registered as a tool for that execution of the command.

Later on I'll probably add python_tools: YAML keys to templates.

Originally posted by @simonw in #990

I'll borrow code from https://github.com/simonw/sqlite-utils/blob/094b010fd870e9fe9f020d4df200d4de7f27209b/sqlite_utils/cli.py#L3277

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions