108 Commits

Author SHA1 Message Date
Eldar Shlomi b7e213282d docs: fix wrong hook name and typo in register_fragment_loaders section (#1489)
The description of the `register_fragment_loaders` hook incorrectly
referred to `register_template_loaders` as the hook to use. These are
two distinct hooks; fragment loader plugins must use
`register_fragment_loaders`.

Also fixed a typo: "de-duplicatino" → "de-duplication".

AI-assisted contribution.
2026-06-15 10:00:48 -07:00
Simon Willison 73bb0221b2 Guaranteed tool call IDs (#1481)
* Guarantee every tool call has a unique tool_call_id

add_tool_call() now synthesizes a unique tc_-prefixed id (monotonic
ULID) whenever the provider did not supply one. Previously consumers
correlating tool calls with results - or keying external state on a
specific invocation - had to invent fallback matching schemes for
id-less providers, and test models like llm-echo exercised different
code paths than production providers.

Provider-supplied ids are preserved untouched, and responses
rehydrated from the logs database keep their stored ids (synthesis
only happens at add_tool_call time). Existing tests that asserted
tool_call_id None now normalize or mask the synthesized ids.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 14:04:26 -07:00
Simon Willison 8aba606447 Release 0.32a2
Test / test (macos-latest, 3.10) (push) Waiting to run
Test / test (macos-latest, 3.11) (push) Waiting to run
Test / test (macos-latest, 3.12) (push) Waiting to run
Test / test (macos-latest, 3.13) (push) Waiting to run
Test / test (macos-latest, 3.14) (push) Waiting to run
Test / test (ubuntu-latest, 3.10) (push) Waiting to run
Test / test (ubuntu-latest, 3.11) (push) Waiting to run
Test / test (ubuntu-latest, 3.12) (push) Waiting to run
Test / test (ubuntu-latest, 3.13) (push) Waiting to run
Test / test (ubuntu-latest, 3.14) (push) Waiting to run
Test / test (windows-latest, 3.10) (push) Waiting to run
Test / test (windows-latest, 3.11) (push) Waiting to run
Test / test (windows-latest, 3.12) (push) Waiting to run
Test / test (windows-latest, 3.13) (push) Waiting to run
Test / test (windows-latest, 3.14) (push) Waiting to run
Refs #1432, #1433, #1435, #1441, #1442
2026-05-12 10:43:00 -07:00
Simon Willison 5a2e0a4c54 --hide-reasoning and hide_reasoning=True parameters (#1442)
* Rename --no-reasoning flag to --hide-reasoning
* hide_reasoning= Prompt parameter, plus docs
* OpenAI plugin now obeys prompt.hide_reasoning
2026-05-12 09:24:51 -07:00
Simon Willison 926394aecd Tweaked some overly-promotional language
Test / test (macos-latest, 3.10) (push) Waiting to run
Test / test (macos-latest, 3.11) (push) Waiting to run
Test / test (macos-latest, 3.12) (push) Waiting to run
Test / test (macos-latest, 3.13) (push) Waiting to run
Test / test (macos-latest, 3.14) (push) Waiting to run
Test / test (ubuntu-latest, 3.10) (push) Waiting to run
Test / test (ubuntu-latest, 3.11) (push) Waiting to run
Test / test (ubuntu-latest, 3.12) (push) Waiting to run
Test / test (ubuntu-latest, 3.13) (push) Waiting to run
Test / test (ubuntu-latest, 3.14) (push) Waiting to run
Test / test (windows-latest, 3.10) (push) Waiting to run
Test / test (windows-latest, 3.11) (push) Waiting to run
Test / test (windows-latest, 3.12) (push) Waiting to run
Test / test (windows-latest, 3.13) (push) Waiting to run
Test / test (windows-latest, 3.14) (push) Waiting to run
2026-04-28 17:46:07 -07:00
Simon Willison 02c9af048f A bunch of documentation edits 2026-04-28 17:07:51 -07:00
Simon Willison 5789bc9e36 It's actually the 0.32 alpha 2026-04-28 16:59:11 -07:00
Simon Willison 3b0d0fa0a5 part_index is now (mostly) automatically assigned 2026-04-28 09:35:53 -07:00
Simon Willison d11b9a01c5 More documentation tweaks 2026-04-22 08:43:15 -07:00
Simon Willison 8c48dccc94 docs: advanced-model-plugins.md covers StreamEvent / prompt.messages / provider_metadata
Substantially expanded docs/plugins/advanced-model-plugins.md with
the plugin-author guide to the new machinery. Distilled from the
actual llm-anthropic and llm-gemini implementations so plugin
authors have a recipe that mirrors what real providers do.

New / updated sections (doc grew 317 → 663 lines):

- "Attachments from previous conversations" trimmed to a pointer at
  prompt.messages — the old pattern of walking conversation.responses
  is replaced by the canonical chain view.

- "Structured messages and streaming events"
  - StreamEvent contract, backward compat for plain-str plugins
  - Full field reference (type / chunk / part_index / tool_call_id /
    provider_metadata / server_executed / tool_name)
  - part_index allocation rules with two worked examples:
    block-keyed (Anthropic-style content_block_start events) and
    kind-tracking (Gemini-style chunk-per-part)
  - Reasoning: streamed text + opaque _reasoning_token_count, with
    the OpenAI-specific gotcha about reading reasoning_tokens BEFORE
    set_usage mutates the dict
  - Tool calls — tool_call_name + tool_call_args pattern, reminder
    that response.add_tool_call() is separately required for
    chain-execution
  - Server-side tools — server_executed=True on events, raw payload
    in provider_metadata for round-trip, post-stream emission for
    providers that don't stream tool-result contents
  - Opaque provider_metadata — Anthropic signature, Gemini
    thoughtSignature, OpenAI encrypted_content — with namespacing
    guidance
  - Non-streaming path — one event per content block

- "Consuming prompt.messages in build_messages"
  - The invariant: prompt.messages is always the full chain; don't
    walk conversation.responses (would double-emit)
  - Worked build_messages example that dispatches per Part subtype
  - Role mapping across OpenAI / Anthropic / Gemini conventions
  - Role-alternation merging

- "Restoring opaque metadata on subsequent requests"
  - How to read provider_metadata off prior-turn Parts and fold the
    signatures back into the outgoing request body

670 tests still green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-21 21:54:01 -07:00
Simon Willison 1562a8f444 Added some more autoclass docs, with new doctrings 2026-03-31 12:54:00 -07:00
Simon Willison 49d4e54639 register_models() model_aliases parameter 2026-03-31 12:45:38 -07:00
Simon Willison 4292fe9d21 Relase 0.27
Refs #1009, #1014, #1049, #1053, #1088, #1104, #1110, #1111, #1114, #1117, #1134, #1137, #1148, #1150, #1177, #1228, #1229, #1232
2025-08-11 13:55:05 -07:00
Simon Willison 08094082f2 Toolbox.add_tool(), prepare() and prepare_async() methods
Closes #1111
2025-08-11 13:19:31 -07:00
Simon Willison a3a2996fed Tools in templates (#1138)
Closes #1009
2025-05-30 17:44:52 -07:00
Simon Willison 796e8952e8 Deploy advanced-model-plugins.md
!stable-docs

Refs #1137
2025-05-29 22:27:48 -07:00
Simon Willison 2fd6c09db1 More labels in docs 2025-05-28 08:02:32 -07:00
Simon Willison f2cf81e29a Move LLM_RAISE_ERRORS to advanced model plugins, closes #1121 2025-05-28 08:02:25 -07:00
Simon Willison 301db6d76c responses.resolved_model column and response.set_resolved_model(model_id) method, closes #1117 2025-05-28 07:17:03 -07:00
Simon Willison afb170a62a llm-fragments-reader
!stable-docs
2025-05-27 20:11:11 -07:00
Dan Turkel 64f78e3867 add four new plugins to directory (#1115) 2025-05-27 20:06:46 -07:00
Dan Turkel cbe304a6ea document register_embedding_models hook (#1049)
* document register_embedding_models hook
2025-05-27 20:00:58 -07:00
Simon Willison fed9573629 Tools section in plugin directory
!stable-docs

Closes #1110
2025-05-27 14:20:05 -07:00
Simon Willison fe7a1f0ee7 Tweaked header 2025-05-27 13:06:12 -07:00
Simon Willison e23e13e6c7 Test for async toolbox, docs for toolboxes in general
Closes #1090, refs #997
2025-05-26 10:23:03 -07:00
Simon Willison 218bd10d6d Include dataclasses in plugin tool docs
Refs #1000

Refs https://github.com/simonw/llm/issues/997#issuecomment-2873497310
2025-05-26 10:05:10 -07:00
Simon Willison 35d460c5e3 How to add tool support to model plugins, closes #1000 2025-05-26 09:57:04 -07:00
Simon Willison 7eb8acb767 llm.get_key() is now a documented utility, closes #1094
Refs #1093, https://github.com/simonw/llm-tools-datasette/issues/2
2025-05-26 09:39:40 -07:00
Simon Willison bb336d33a0 Toolbox class for class-based tool collections (#1086)
* Toolbox class for class-based tool collections

Refs #1059, #1058, #1057
2025-05-25 22:42:52 -07:00
Benjamin Kirkbride ccc52265e9 fix typo in tutorial-model-plugin.md (#1043) 2025-05-23 23:33:40 -07:00
Simon Willison 88b806ae1a Got multi-tool OpenAI chat working, in no-stream mode too
Refs #1017, #1019
2025-05-13 17:19:30 -07:00
Simon Willison 4abd6e0faf Made a start on tools.md docs, refs #997
Also documented register_tools() plugin hook, refs #991
2025-05-13 17:19:30 -07:00
Simon Willison cb1ea231dc Example docstrings for fragment loaders
!stable-docs
2025-05-08 19:05:50 -07:00
Simon Willison f07655715e llm-video-frames
!stable-docs

Refs https://github.com/simonw/llm-video-frames/issues/2
2025-05-04 20:47:14 -07:00
Samuel Dion-Girardeau 00e5ee6b5a Add llm-fragments-pypi to plugin directory (#929)
As the name suggests, this plugin gets PyPI packages as fragments.
Namely the project metadata and description.

See README for more usage examples:
https://github.com/samueldg/llm-fragments-pypi?tab=readme-ov-file#usage
2025-05-04 15:34:52 -07:00
Simon Willison e02863c1ca Fragment plugins can now optionally return attachments (#974)
Closes #972
2025-05-04 14:50:27 -07:00
Simon Willison 9a39af82cd Tip about lazy loading dependencies, closes #949
!stable-docs
2025-04-23 10:55:13 -07:00
Simon Willison bf622a27cc Fabric plugin now uses fabric:
https://github.com/simonw/llm-templates-fabric/issues/2

!stable-docs
2025-04-07 22:23:30 -07:00
Simon Willison fd6b2d786a Fragments and template loaders
!stable-docs

Refs #809, #886
2025-04-07 22:12:26 -07:00
Simon Willison a571a4e948 register_fragment_loaders() hook (#886)
* Docs and shape of register_fragment_loaders hook, refs #863
* Update docs for fragment loaders returning a list of FragmentString
* Support multiple fragments with same content, closes #888
* Call the pm.hook.register_fragment_loaders hook
* Test for register_fragment_loaders hook
* Rename FragmentString to Fragment

Closes #863
2025-04-06 17:03:34 -07:00
Simon Willison 6c9a8efb50 register_template_loaders plugin hook, closes #809
* Moved templates CLI commands next to each other
* llm templates loaders command
* Template loader tests
* Documentation for template loaders
2025-03-21 16:46:44 -07:00
Simon Willison 090e971bf4 Model feature list for advanced plugins documentation
!stable-docs
2025-03-19 21:43:17 -07:00
Simon Willison 8d32b71ef1 Renamed build_json_schema to schema_dsl 2025-02-27 10:22:29 -08:00
Simon Willison 62c90dd472 llm prompt --schema X option and model.prompt(..., schema=) parameter (#777)
Refs #776

* Implemented new llm prompt --schema and model.prompt(schema=)
* Log schema to responses.schema_id and schemas table
* Include schema in llm logs Markdown output
* Test for schema=pydantic_model
* Initial --schema CLI documentation
* Python docs for schema=
* Advanced plugin docs on schemas
2025-02-26 16:58:28 -08:00
Simon Willison e46cb7e761 Update docs to no longer mention PaLM
!stable-docs
2025-02-16 22:37:00 -08:00
Simon Willison 64f9f2ef52 Promote llm-mlx in changelog and plugin directory
!stable-docs
2025-02-16 22:29:32 -08:00
Simon Willison 6c6b100f3e KeyModel and AsyncKeyModel classes for models that taken keys (#753)
* New KeyModel and AsyncKeyModel classes for models that taken keys - closes #744
* llm prompt --key now uses new mechanism, including for async
* use new key mechanism in llm chat command
* Python API tests for llm.KeyModel and llm.AsyncKeyModel
* Python API docs for for prompt(... key="")
* Mention await model.prompt() takes other parameters, reorg sections
* Better title for the model tutorial
* Docs on writing model plugins that take a key
2025-02-16 14:38:51 -08:00
Simon Willison 21df241443 llm-claude-3 is now called llm-anthropic
Refs https://github.com/simonw/llm-claude-3/issues/31

!stable-docs
2025-02-01 22:08:19 -08:00
Simon Willison e449fd4f46 Typo fix
!stable-docs
2025-01-22 22:17:07 -08:00
Ryan Patterson 59983740e6 Update directory.md (#666) 2025-01-18 14:52:51 -08:00