提交

1019 次代码提交

作者 SHA1 备注 提交日期
Simon Willison 7c0a192341 Reformatted with Black
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-04-12 17:18:37 -07:00
Simon Willison 1280082b6d Rename prompt.input_parts to prompt.parts 2026-04-12 17:17:42 -07:00
Simon Willison 1610030020 Default OpenAI plugin now handles .prompt(parts=[...]) 2026-04-07 12:18:51 -07:00
Simon Willison 226d73d805 Only package llm and llm.* 2026-04-06 14:13:19 -07:00
Simon Willison 9a44bb29c6 Add option 8 (short names in llm.parts) to sugar ideas, update recommendation
New option: from llm.parts import Text then Text.system("..."),
Text.user("..."). Combined with role classmethods this is very
concise. Notes the Attachment/ToolCall name collision issue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 08:19:52 -07:00
Simon Willison 4a2d4bc31f Add syntactic sugar ideas for parts=[] API
Seven options explored: role-based classmethods, top-level shortcuts,
chainable builder, tuples, dicts, hybrid, and messages= alias.
Recommends starting with classmethods then adding llm.user()/system()
shortcuts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 08:15:27 -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 ed223991cf Update plugin upgrade guide with lessons from llm-mistral conversion
Add notes about: requiring response.add_tool_call() alongside StreamEvents
for tool calls, yield from limitation in async generators, filtering empty
text chunks, and astream_events() vs stream_events() for async.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 09:06:02 -07:00
Simon Willison 2949373d50 Add generic plugin upgrade guide for StreamEvent/parts support
Covers: importing StreamEvent, converting yield str to yield
StreamEvent for text/reasoning/tool calls/server-side tools, part
index tracking, handling opaque reasoning tokens, testing patterns,
and the special case of plugins that inherit from built-in models.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 08:55:16 -07:00
Simon Willison 3be4505317 Add TODO about spurious space TextPart from Anthropic tool workaround
Documents the " " space character that gets persisted as a real
TextPart when the Anthropic plugin works around a text-joining bug
in tool call chains. Lists four options to fix, recommends moving
the spacing concern to the display layer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 08:07:02 -07:00
Simon Willison 018217d624 Add newline at reasoning-to-text transition, extract display helper
display_stream_events() helper handles writing text to stdout and
reasoning to stderr with proper newlines at each reasoning-to-text
transition. Used by sync prompt and chat streaming loops. Async prompt
loop has the same logic inline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:59:54 -07:00
Simon Willison 05f5ed3943 CLI displays reasoning on stderr, adds -R/-S/-L shortcuts
Streaming loops in prompt and chat commands now use stream_events()
instead of __iter__. Reasoning events are displayed on stderr in
dim text. Text events go to stdout as before.

New flags:
  -R / --no-reasoning  Suppress reasoning output on stderr
  -S / --no-stream     (shortcut for existing --no-stream)
  -L                   (shortcut for existing -n/--no-log)

ChainResponse.stream_events() and AsyncChainResponse.astream_events()
added so tool-calling flows also surface reasoning events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:53:25 -07:00
Simon Willison 2c3d966262 Final implementation notes for all 5 phases
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:42:49 -07:00
Simon Willison 0205bec5d1 Database migration and persistence for parts (Phase 5)
New m022_parts_table migration creates a parts table with direction
(input/output), role, part_type, content, content_json, tool_call_id,
and server_executed columns.

log_to_db() writes both input parts (from prompt.input_parts) and
output parts (from response.parts) to the table. from_row() loads
output parts and makes them available via the parts property.

Tested live: parts table created, input/output parts written and
loaded correctly with gpt-5.4-mini via CLI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:42:26 -07:00
Simon Willison 5194bb766f Add parts= parameter and input_parts property (Phase 4)
model.prompt() and conversation.prompt() now accept a parts= parameter
for passing explicit Part objects. Prompt.input_parts synthesizes a
unified list of input Parts from prompt=, system=, attachments=, and
parts= parameters.

prompt= remains sugar for a TextPart(role="user"). system= becomes
a TextPart(role="system"). attachments= become AttachmentParts.
All parameters combine (parts first, then system, then prompt, then
attachments).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:38:45 -07:00
Simon Willison fe4243710b Update implementation notes with Phase 3 observations
Documents findings from all three plugin implementations: OpenAI
(set_usage mutation, opaque reasoning), Anthropic (streamed thinking,
server-side tools), Gemini (opaque thinking, complete parts per chunk).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:35:32 -07:00
Simon Willison 0367001d18 OpenAI plugin emits StreamEvent objects (Phase 3)
Chat.execute() and AsyncChat.execute() now yield StreamEvent instead
of bare strings. Text chunks, tool call names/args are all emitted
as typed events. Reasoning token counts from usage data are stored
on the response and _build_parts() prepends a redacted ReasoningPart.

StreamEvent gains server_executed and tool_name fields for use by
plugins with server-side tool execution.

Tested live against gpt-5.4-mini: text streaming, tool calls, and
reasoning tokens (with reasoning_effort='high') all work correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-05 07:24:40 -07:00
Simon Willison 9e0c213ba4 Add implementation notes from Phase 1 and Phase 2
Documents design decisions, live testing observations against
gpt-5.4-mini, and things to watch for in Phase 3.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 23:24:42 -07:00
Simon Willison a8e7b63604 Teach Response to handle StreamEvent from plugins (Phase 2)
Response.__iter__ now handles str | StreamEvent from execute().
Plain str yields are backward compatible. StreamEvent yields are
processed by the assembler: text events yield as str to consumers,
reasoning/tool_call/tool_result events are filtered from __iter__
but available via stream_events(). Parts are assembled from events
after completion. Same changes for AsyncResponse.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 23:23:22 -07:00
Simon Willison c774a22ab9 Export Part types and StreamEvent from llm package
All new types are now accessible as llm.TextPart, llm.StreamEvent, etc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 23:20:10 -07:00
Simon Willison 350469f266 Add stream_events() and parts property to Response/AsyncResponse
Response.stream_events() yields StreamEvents wrapping text chunks.
AsyncResponse.astream_events() is the async equivalent.
response.parts returns a list of Part objects after completion.
Currently only handles plain str chunks (Phase 1 baseline).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 23:18:57 -07:00
Simon Willison af1311de23 Part types and StreamEvent dataclasses with serialization
Phase 1 of the parts project: define the Part dataclass hierarchy
(TextPart, ReasoningPart, ToolCallPart, ToolResultPart, AttachmentPart)
and StreamEvent in a new llm/parts.py module. All Part types have
to_dict()/from_dict() for JSON roundtripping. 14 tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 23:17:34 -07:00
Simon Willison 8f98ff725e Plan by Claude Code 2026-04-04 23:08:36 -07:00
Simon Willison ad4f83c794 Ignore the research directory 2026-04-04 09:44:02 -07:00
Simon Willison 10703b7e03 Initial overview for LLM plans project 2026-04-04 09:41:26 -07:00
Simon Willison cad03fb4f4 Register async models for extra-openai-models.yaml, closes #1395
Note that Completion models do not have an async class so will not be registered as async.
2026-04-04 07:07:14 -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
0.30
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
0.29
2026-03-17 12:23:43 -07:00
Simon Willison b8cb53a2a1 Release 0.29
Refs #1322, #1376
2026-03-17 12:19:13 -07:00
Simon Willison c8889e0a76 Ran black 2026-03-17 11:25:12 -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 683ca204b2 Ensure -x/--xl work with -t 2026-03-17 11:22:34 -07:00
Claude 947feaa0c9 Add gpt-5.4 and gpt-5.4-2026-03-05 model support
https://claude.ai/code/session_01HwqZ4WeDCrspfF8E7STiPA
2026-03-06 00:42:46 +00:00
Simon Willison 6b84a0d36b Only do model_aluases=get_model_aliases() if needed by --save
I do not think this prevents hitting all the plugins for every prompt though
but it least we no longer hit all the plugins twice.
2026-01-19 13:19:57 -08:00
Simon Willison 5d237ce6ce Show options in Markdown logs output, closes #1322 2025-12-17 22:19:33 -08: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
0.28
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 e0b44bc5ab Fix some test warnings, refs #1312 2025-12-11 14:37:47 -08:00
Eric Bloch f7934c5c26 Fix some descriptor leaks (#1313)
Refs #1312
2025-12-11 14:20:58 -08:00
Arjan Mossel 73548c479a Add type annotations for OpenAI Chat/AsyncChat/Completion execute methods (#1315)
* Add type annotations for OpenAI Chat/AsyncChat/Completion execute methods
* Add type hint for OpenAI _Shared class
* cast(Response) to make mypy happy

Co-authored-by: Simon Willison <swillison@gmail.com>
2025-12-11 14:17:17 -08:00
Giuseppe Rota 618463de13 fix: register fragment source in chat command (#1316)
* Register fragment source in chat command
2025-12-11 13:54:32 -08:00
Simon Willison abf77e40d8 Fix for cog 2025-12-11 13:20:06 -08:00
Simon Willison dd227cdcd1 Drop Python 3.9, add 3.14 2025-12-11 13:19:34 -08:00