文件历史

569 次代码提交

作者 SHA1 备注 提交日期
Simon Willison 82b1f4c17a Docs: rewrite parts/messages section around messages= API
- python-api.md: 'Parts and stream events' section reworks the example
  code around response.messages[].parts and drops the old parts=
  parameter docs. New 'Prompting with messages' section shows the
  user/assistant/system/tool_message helpers, parallel tool calls as
  one assistant message, and Attachment-as-positional-arg.
- advanced-model-plugins.md: plugin author guide walks prompt.messages
  instead of the old flat prompt.parts + legacy fields. provider_metadata
  example no longer passes role= to TextPart; storage reference updated
  to message_parts table.
2026-04-12 21:50:46 -07:00
Simon Willison 5217a0bace Parts: serialization round-trip, stream safety, provider_metadata
Round out the parts API so transcripts survive serialization and so
providers can stash opaque multi-turn state on parts and stream events.

Serialization:
- AttachmentPart.from_dict now supported; inline content bytes round-trip
  as base64.
- ToolResultPart.attachments round-trip through to_dict/from_dict.

Stream assembler:
- _build_parts raises ValueError when an incompatible StreamEvent type
  appears at the same part_index, instead of silently overwriting the
  earlier part. tool_call_name and tool_call_args stay compatible.

OpenAI parts=[] support:
- build_messages emits assistant tool_calls and role:"tool" messages for
  ToolCallPart and ToolResultPart passed via parts=.

provider_metadata:
- New optional dict on TextPart, ReasoningPart, ToolCallPart,
  ToolResultPart, and StreamEvent for opaque provider data that must be
  echoed back on the next request (Anthropic signature/encrypted_content,
  Gemini thoughtSignature, OpenAI Responses encrypted_content).
- StreamEvent values merge onto the finalized Part per top-level namespace
  key, last non-None wins.
- Persisted via existing content_json column and reloaded by
  _load_parts_from_db; no schema change.
- Plugin author guide in docs/plugins/advanced-model-plugins.md.

Types:
- Widen execute() return types to Iterator[str | StreamEvent] /
  AsyncGenerator[str | StreamEvent, None] on abstract Model/AsyncModel
  bases and OpenAI Chat implementations.
- Initialize _reasoning_token_count on _BaseResponse so mypy stops
  flagging the OpenAI plugin.
2026-04-12 20:59:21 -07:00
Simon Willison 1280082b6d Rename prompt.input_parts to prompt.parts 2026-04-12 17:17:42 -07:00
Simon Willison 1df6dc5a26 Document parts, stream_events, and parts= parameter in Python API docs
New sections cover:
- response.parts for structured access to text, reasoning, tool calls
- ReasoningPart with both streamed (Anthropic) and redacted (OpenAI) examples
- ToolCallPart and ToolResultPart
- stream_events() / astream_events() for rich real-time streaming
- parts= parameter for constructing prompts with typed parts
- prompt.input_parts for unified view of all input parts
- All part types listed with serialization methods

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 07:15:17 -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
Simon Willison 07dccc00ef GPT-5.4, 5.4-mini, 5.4-nano
Closes #1376
2026-03-17 11:24:52 -07:00
Simon Willison 4766f47946 Note about just cog in release process
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
See 8002325600
2025-12-12 12:01:37 -08:00
Simon Willison 8002325600 Cog for 0.28 release 2025-12-12 12:00:22 -08:00
Simon Willison 3a4f639536 Release 0.28
Refs #1300, #1308, #1309, #1313, #1315, #1316, #1317, #1318
2025-12-12 11:58:35 -08:00
Simon Willison abf77e40d8 Fix for cog 2025-12-11 13:20:06 -08:00
Simon Willison 1e3c7f0cfd uv and dependency-groups, refs #1318 2025-12-11 13:18:20 -08:00
Simon Willison 1753eb74ee gpt-5.2, gpt-5.2-chat-latest - refs #1317 2025-12-11 11:50:08 -08:00
Simon Willison a0ac68c452 Custom HTTP user-agent for llm -f URL, closes #1309 2025-11-25 22:07:11 -08:00
Simon Willison 921fae9a0a Release 0.27.1
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.9) (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.9) (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.9) (push) Has been cancelled
Refs #1237, #1238, #1239. #1240
2025-08-11 22:14:55 -07:00
Simon Willison e15e1ad717 Credit James Sanford in changelog, refs #1218, #1232
Test / test (macos-latest, 3.9) (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.9) (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 (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 (windows-latest, 3.9) (push) Has been cancelled
2025-08-11 14:29:35 -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 cbd3aab511 GPT-5 model IDs, refs #1229 2025-08-11 13:23:36 -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 ef3192b44d Better docs for OpenAI model options
!stable-docs

Closes #1228
2025-08-03 15:31:25 -07:00
Simon Willison 24f32fe7b4 Grant models the ability to execute tools 2025-06-19 13:21:03 -07:00
Simon Willison 0863ed460e llm logs -l/--latest -q option, closes #1177 2025-06-17 23:23:45 -07:00
Simon Willison 12b6ea6977 Fix grammar in attachments docs 2025-06-03 15:48:07 -07:00
Simon Willison 3a96d52895 Better handling of before_call cancellation, closes #1148 2025-06-01 18:36:55 -07:00
Simon Willison 30e0c4abe8 ToolResult.exception for tool errors, now logged to DB
Closes #1104
2025-06-01 17:01:40 -07:00
Simon Willison e6dcd414a5 note about async before_call/after_call 2025-06-01 12:36:28 -07:00
Sukhbinder Singh f5a38d3342 Add -h shortcut for --help
Closes #983, #1134
2025-06-01 12:31:02 -07:00
Simon Willison ed64fc3362 chain_limit/before_call/after_call for conversations
* chain_limit/before_call/after_call for conversations, closes #1088
* Docs for before_call/after_call including for model.conversation
2025-06-01 12:00:29 -07:00
Simon Willison b5d1c5ee90 Tools can now return attachments
Closes #1014

- llm.ToolOutput(output='...', attachments=[...]) for tools to return attachments
- New table: `tool_results_attachments`
- Table is populated when tools return attachments
- llm --tools-debug shows attachments returned by tools
- llm logs shows attachments returned by tools
2025-06-01 10:08:36 -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 045d00ed98 Bump copyright year in docs 2025-05-27 19:46:40 -07:00
Simon Willison fed9573629 Tools section in plugin directory
!stable-docs

Closes #1110
2025-05-27 14:20:05 -07:00
Simon Willison c6b2f2681a Release 0.26
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.9) (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.9) (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.9) (push) Has been cancelled
Refs #1000, #1089, #1094, #1096, #1097, #1099, #1103, #1066
2025-05-27 13:32:59 -07:00
Simon Willison eddcf480e3 Show tool_instances on logging.md, refs #1089 2025-05-27 13:28:46 -07:00
Simon Willison fe7a1f0ee7 Tweaked header 2025-05-27 13:06:12 -07:00
Simon Willison 2bc6d7679c New default tool, llm_time, closes #1103 2025-05-26 23:00:18 -07:00
Simon Willison cc017a7f84 Note that llm -c and toolboxs don't work yet
Refs #1092, #1101
2025-05-26 22:07:44 -07:00