- 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.
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.
* 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
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
* 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
- https://github.com/simonw/llm/issues/507#issuecomment-2458639308
* register_model is now async aware
Refs https://github.com/simonw/llm/issues/507#issuecomment-2458658134
* Refactor Chat and AsyncChat to use _Shared base class
Refs https://github.com/simonw/llm/issues/507#issuecomment-2458692338
* fixed function name
* Fix for infinite loop
* Applied Black
* Ran cog
* Applied Black
* Add Response.from_row() classmethod back again
It does not matter that this is a blocking call, since it is a classmethod
* Made mypy happy with llm/models.py
* mypy fixes for openai_models.py
I am unhappy with this, had to duplicate some code.
* First test for AsyncModel
* Still have not quite got this working
* Fix for not loading plugins during tests, refs #626
* audio/wav not audio/wave, refs #603
* Black and mypy and ruff all happy
* Refactor to avoid generics
* Removed obsolete response() method
* Support text = await async_mock_model.prompt("hello")
* Initial docs for llm.get_async_model() and await model.prompt()
Refs #507
* Initial async model plugin creation docs
* duration_ms ANY to pass test
* llm models --async option
Refs https://github.com/simonw/llm/pull/613#issuecomment-2474724406
* Removed obsolete TypeVars
* Expanded register_models() docs for async
* await model.prompt() now returns AsyncResponse
Refs https://github.com/simonw/llm/pull/613#issuecomment-2475157822
---------
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>