文件历史

607 次代码提交

作者 SHA1 备注 提交日期
Simon Willison 0392226e66 Release notes for 0.31.1
Update Stable Docs / update_stable_docs (push) Has been cancelled
Test / test (macos-latest, 3.10, ) (push) Has been cancelled
Test / test (macos-latest, 3.11, ) (push) Has been cancelled
Test / test (macos-latest, 3.12, ) (push) Has been cancelled
Test / test (macos-latest, 3.13, ) (push) Has been cancelled
Test / test (macos-latest, 3.14, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14, ) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14, 4.0rc4) (push) Has been cancelled
Test / test (windows-latest, 3.10, ) (push) Has been cancelled
Test / test (windows-latest, 3.11, ) (push) Has been cancelled
Test / test (windows-latest, 3.12, ) (push) Has been cancelled
Test / test (windows-latest, 3.13, ) (push) Has been cancelled
Test / test (windows-latest, 3.14, ) (push) Has been cancelled
Refs #1521
2026-07-09 09:07:51 -07:00
Simon Willison ef2eadf768 Only run cog check on sqlite-utils 4.0rc2
Refs https://github.com/simonw/sqlite-utils/issues/758#issuecomment-4886940409
2026-07-05 10:32:16 -07:00
Labib Bin Salam af977da5ca Fix typos in documentation (#1486)
- tools.md: drop the stray article in "every tool is a defined as" and the doubled word in "Toolbox classes can be be configured".
- contributing.md: fix the doubled "an an" in the example prompt (both the streaming and --no-stream snippets).
2026-06-15 10:01:40 -07:00
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 5fe711964e Update docs/fragments.md 2026-06-09 15:31:54 -07:00
Simon Willison 1e72f0a0e4 Spelling for Datasette Agent
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
2026-06-09 15:25:37 -07:00
Simon Willison 2ae7089508 Release 0.32a3
Refs #1480, #1481, #1482, #1482, #1482, #1483
2026-06-09 15:25:01 -07:00
Simon Willison 3ac0a23381 PauseChain primitive + chain resume from pending tool calls (#1482)
* PauseChain primitive + chain resume from pending tool calls

Two features that together give chains a first-class suspend/resume
story for human-in-the-loop tools:

llm.PauseChain: raise inside a tool implementation to stop the chain
cleanly. Unlike other exceptions it is not converted into an error
ToolResult - it propagates to the caller with .tool_call (the paused
call) and .tool_results (completed sibling results) attached, and no
provider call is made with a placeholder result. Failure semantics
for concurrent tool execution are now defined: async sibling tasks
always run to completion before a pause or hook exception propagates
(gather with return_exceptions, raised after collection), so nothing
is orphaned mid-flight; sync execution stops at the paused call,
leaving later calls unstarted so they can safely run on resume.

Chain resume: chain(messages=history, tools=...) now detects a
history ending in an assistant message with unresolved tool calls -
e.g. one persisted when a previous run paused or crashed - executes
those calls through the normal before_call/after_call machinery
(skipping any that already have results), then sends the results to
the model as a standard tool-result turn. A resumed call may pause
again, enabling multi-question flows. Histories where a user or
assistant message follows the calls are left alone. Also adds
execute_tool_calls(tool_calls_list=) for executing an explicit list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 15:07:27 -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 b865ede0f1 Tool implementations can receive the ToolCall via llm_tool_call param (#1480)
* Tool implementations can receive the ToolCall via llm_tool_call parameter

Tool functions (sync or async, including Toolbox methods) that declare
a parameter named llm_tool_call are now passed the llm.ToolCall object
for the current invocation. The parameter is reserved: it is excluded
from the input schema exposed to the model and is only injected when
declared explicitly - a **kwargs catch-all does not receive it.

This lets tool implementations key external state against the unique
tool_call_id, e.g. for human-in-the-loop approval flows that need to
resume a specific tool call after the answer arrives.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Ran Black

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 13:51:39 -07:00
Simon Willison be27b91aa8 Fixed broken link 2026-05-16 18:38:18 -07:00
Simon Willison 8aba606447 Release 0.32a2
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
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 74437d3dfe "llm -m model --options" to see model options 2026-05-12 08:38:47 -07:00
github-actions[bot] 7e6643d87d Ran cog 2026-05-12 05:34:11 +00:00
github-actions[bot] c564fbe24b Ran cog 2026-05-06 04:48:51 +00:00
Simon Willison 3d0321fbb4 Add options= dict parameter to .prompt() and .reply() (#1432)
Accepts model options as an explicit dict alongside the existing
**kwargs form. The kwargs form continues to work unchanged for
backwards compatibility but is no longer documented. Mixing the two
forms with overlapping keys raises TypeError.

Applies to Model.prompt, Conversation.prompt, Response.reply and
their async equivalents. .chain() already used this pattern.

Co-authored-by: Claude <noreply@anthropic.com>
2026-05-04 20:57:01 -07:00
Simon Willison 9a5c24e20c Release 0.32a1
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
Refs #1426

Refs https://github.com/simonw/llm-anthropic/issues/68
2026-04-29 16:52:09 -07:00
Simon Willison cce6ed956a Ran cog 2026-04-29 12:02:36 -07:00
Simon Willison 35c35dac43 Release 0.32a0
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
Closes #1314, #506, #1278, #894, #813, #468, #346, #716, #770, #867, #938, #1033, #937

Refs #1067, #1080
2026-04-29 11:55:20 -07:00
Simon Willison 926394aecd Tweaked some overly-promotional language
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
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 35c7533c18 Edited the changelog for 0.32a0 2026-04-28 16:49:05 -07:00
Simon Willison 29e3787be5 Draft changelog for 0.32a0 2026-04-28 16:32:52 -07:00
Simon Willison b97a6902f5 Persist visible reasoning to logs and render in markdown
Adds a `reasoning` column to the responses table (migration m022)
populated from concatenated visible-reasoning text in the assembled
message. `llm logs --md` renders it under a `## Reasoning` heading
above the response when present.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 14:27:22 -07:00
Simon Willison 842ab2a93f response.messages is a method, matching .text() / .json() / .tool_calls()
Sync: response.messages() forces execution if not drained, so callers
no longer have to remember to call .text() first. Async: `await
response.messages()` awaits the force.

Internal sync paths (_response_to_dict, _chain_for_tool_results,
_build_full_chain, Response.reply, AsyncResponse.reply) use a new
private _messages_now() helper that assumes the response is already
drained, so they don't have to await on async responses.

Drops the now-obsolete "accessing .messages on un-awaited
AsyncResponse raises" parity test — that constraint goes away with
the method form.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 14:04:35 -07:00
Simon Willison f3a0962162 response.reply() auto-executes pending tool calls
Zero-arg sugar: when a response made tool calls and tool_results= is
not passed, reply() runs self.execute_tool_calls() and threads the
results into the next turn. Pass tool_results= explicitly to skip
the auto-execute path (e.g. for mutated or synthetic results). Also
forwards self.prompt.tools to the next turn so the model can call
the same tools again, mirroring Conversation.prompt's tools-or-self
rule.

AsyncResponse.reply() is now an awaitable coroutine — `await
response.reply(...)` — so the auto-execute path can `await
self.execute_tool_calls()` internally. This is a non-shipped API
break: existing async-reply callers in the test suite updated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 13:51:13 -07:00
Simon Willison 3b0d0fa0a5 part_index is now (mostly) automatically assigned 2026-04-28 09:35:53 -07:00
Simon Willison 6567b60005 Merge remote-tracking branch 'origin/messages-refactor' into messages-refactor
# Conflicts:
#	docs/fragments.md
#	llm/default_plugins/openai_models.py
#	pyproject.toml
2026-04-28 07:34:02 -07:00
Simon Willison 13b10e097c Merge remote-tracking branch 'origin/main' into messages-refactor
# Conflicts:
#	llm/default_plugins/openai_models.py
2026-04-28 07:31:55 -07:00
Simon Willison 5ce40fd703 Release 0.31
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
Refs #1418
2026-04-24 16:33:05 -07:00
Simon Willison 706852ecea New image_detail low/high/auto/original option
Refs https://github.com/simonw/llm/issues/1418#issuecomment-4316983472
2026-04-24 16:22:43 -07:00
Simon Willison 021a29d61a OpenAI verbosity option
Refs https://github.com/simonw/llm/issues/1418#issuecomment-4316867527
2026-04-24 16:08:26 -07:00
Simon Willison c9a3ac9fe0 New model: gpt-5.5 - refs #1418 2026-04-24 15:41:12 -07:00
github-actions[bot] eb45de6bfc Ran cog 2026-04-22 17:18:08 +00: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 92f9359ba3 Documentation improvements 2026-04-21 21:24:50 -07:00
Simon Willison d4f3f242ce Unwrap wrapped text in docs 2026-04-21 20:17:39 -07:00
github-actions[bot] 1c317ab3fe Ran cog 2026-04-22 00:08:41 +00:00
Simon Willison 063564d34d Phase 6: client-side serialization round-trip test + docs
Lock in the "application does its own persistence without SQLite"
story with:

  - Five integration tests covering: Message.to_dict / from_dict
    round-trip, re-inflating messages and continuing a conversation,
    tool calls + results round-trip, redacted reasoning Parts
    round-trip, and provider_metadata round-trip.
  - A new "Structured messages and streaming events" section in
    docs/python-api.md walking users through messages=[...],
    stream_events(), response.messages, and the JSON round-trip
    pattern.

No new code — the machinery landed in Phases 1-3. This phase is
validation + documentation.

580 tests passing overall.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 09:45:50 -07:00
Simon Willison f2c7a2a807 Link to #1389 from changelog 2026-03-31 13:45:24 -07:00
Simon Willison 7169fe9085 Add Usage to llm/__init__ __all__ (to fix Ruff)
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
2026-03-31 13:33:56 -07:00
Simon Willison 62b8864fda Release 0.30 2026-03-31 13:32:04 -07:00
Simon Willison 946e433698 More docstrings and autoclass embeds in docs 2026-03-31 13:12:32 -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 40f7b8f2fa Ran cog 2026-03-31 11:53:25 -07:00
Simon Willison c7cf7e506e Changelog for 0.29
Test / test (macos-latest, 3.10) (push) Has been cancelled
Test / test (macos-latest, 3.11) (push) Has been cancelled
Test / test (macos-latest, 3.12) (push) Has been cancelled
Test / test (macos-latest, 3.13) (push) Has been cancelled
Test / test (macos-latest, 3.14) (push) Has been cancelled
Test / test (ubuntu-latest, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, 3.14) (push) Has been cancelled
Test / test (windows-latest, 3.10) (push) Has been cancelled
Test / test (windows-latest, 3.11) (push) Has been cancelled
Test / test (windows-latest, 3.12) (push) Has been cancelled
Test / test (windows-latest, 3.13) (push) Has been cancelled
Test / test (windows-latest, 3.14) (push) Has been cancelled
2026-03-17 12:23:43 -07:00