文件历史

317 次代码提交

作者 SHA1 备注 提交日期
Simon Willison 8e5ebfc842 Use dag.db as default database
So we do not accidentally mess up logs.db
2026-04-15 15:07:35 -07:00
Simon Willison 527f84fd5d DAG phase 6: llm logs surfaces DAG head pointers via calls join
LOGS_SQL and LOGS_SQL_SEARCH left join the calls table on responses.id
(they share ids by construction). --json output now includes
head_input_message_id and head_output_message_id.

Rows that predate the DAG schema — or historical fixtures that only
wrote to responses — get NULL for those columns, so existing tests
are unaffected. Two new tests cover both cases: real prompt round-trip
(fields populated) and legacy-shape rows (fields NULL).

This is the minimum hook from the Deferred list in plans/dag-schema.md.
Union-read (prefer calls over responses, reconstruct prompt/response
from the DAG) is still deferred — a follow-up once there are calls
rows without matching responses rows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 08:34:35 -07:00
Simon Willison 94cde01b30 DAG phase 4: fork
- MessageStore.fork(source_message_id, name=, model=) creates a new
  conversation rooted at an existing message. The shared prefix is
  reused in place; only one conversations row is written.
- Model defaults to whatever most recently wrote a call touching the
  source message; can be overridden. Raises ValueError if the message
  doesn't exist or no model can be inferred.
- New `llm fork <message_id>` CLI prints the new conversation id.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 08:27:38 -07:00
Simon Willison d833616276 Add messages=[...] parameter to model.prompt()
Accept messages= alongside the existing parts= parameter.
Conversation/AsyncConversation/Model/AsyncModel prompt() forward it to
Prompt, which stores it as prompt.messages.

OpenAI adapter gains _append_message_from_message which translates one
llm.Message into the correct OpenAI message dict(s), including the
parallel-tool-calls case (one assistant message with multiple
ToolCallParts becomes one OpenAI message with a tool_calls array).

Legacy paths untouched: parts=, prompt=, system=, attachments=, and
tool_results= still work when messages= is not set.
2026-04-12 21:10:28 -07:00
Simon Willison f773ab2fa4 Formatting and type annotation fixes 2026-04-12 17:31:21 -07:00
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 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 c8889e0a76 Ran black 2026-03-17 11:25:12 -07:00
Simon Willison 683ca204b2 Ensure -x/--xl work with -t 2026-03-17 11:22:34 -07: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
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 14c2e2ab7e Move the import to a better spot, refs #1309 2025-11-25 22:20:05 -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 c41c122239 Use tools in templates with llm chat, closes #1239 2025-08-11 22:11:17 -07:00
Simon Willison 2f206d0e26 Fix for duplicated prompts in llm chat with templates, closes #1240
Also includes a bug fix for system fragments, see https://github.com/simonw/llm/issues/1240#issuecomment-3177684518
2025-08-11 21:52:54 -07:00
Simon Willison e6ac18fbcb Fix for confusing error, closes #1238 2025-08-11 16:52:16 -07:00
Simon Willison 9f1417f6e8 Fix for enum options and --save, refs #1237 2025-08-11 16:16:27 -07:00
Simon Willison 5204a11f33 Allow -o option when calling tools, closes #1233 2025-08-11 13:44:26 -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 0863ed460e llm logs -l/--latest -q option, closes #1177 2025-06-17 23:23:45 -07:00
Simon Willison d96ae4ed8d Fix --async logging to database, closes #1150 2025-06-01 17:38:26 -07:00
Simon Willison 65dde782b7 Fix mypy warning, closes #1146 2025-06-01 17:03:44 -07:00
Simon Willison 30e0c4abe8 ToolResult.exception for tool errors, now logged to DB
Closes #1104
2025-06-01 17:01:40 -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 fd2f0ffbcd Better error on llm templates show, closes #1053 2025-05-31 17:26:07 -07:00
Simon Willison a3a2996fed Tools in templates (#1138)
Closes #1009
2025-05-30 17:44:52 -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 d1c5c688e2 Error on llm -c with a Toolbox, closes #1101
Refs #1092
2025-05-26 21:51:16 -07:00
Simon Willison 57459c0a6e Fix the tests I broke in #1096 2025-05-26 19:02:14 -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
Simon Willison abc4f473f4 --td now pretty-prints JSON if possible, closes #1083 2025-05-25 12:59:48 -07:00
Simon Willison 7837335eea Remove colon in Token usage header for consistency
More consistent with other headings in logs now.
2025-05-24 16:55:05 -07:00
André Arko fc44fd6a0d llm chat now respects default model options (#985) 2025-05-24 14:24:53 -07:00
Simon Willison a7c51e2871 Don't execute fragments/attachments in !edit sessions, closes #1074 2025-05-23 23:44:24 -07:00
Abizer Lokhandwala 9dace69af7 bugfix: cast path to str in templates_edit (#1031) 2025-05-23 23:34:16 -07:00
Dan Turkel 88d3e11c65 Support fragments in chat through -f, --sf, and !fragments (#1048)
* add vscode and uv artifacts to gitignore
* !fragment feature
* Update fragment command to accept multiple fragments
* Add support for multiple fragments in !fragment command, factor out fragment processing
* Add support for fragment/system fragment arguments in chat command
* update docs

---------

Co-authored-by: Simon Willison <swillison@gmail.com>
2025-05-23 23:31:16 -07:00
Dan Turkel 1d5d73481a Filter IDs with --prefix in llm similar (#1052) 2025-05-23 22:54:55 -07:00
Simon Willison 70092f2e78 llm logs --tools flag, closes #1072 2025-05-23 21:58:24 -07:00
Simon Willison 8a1fc5a90e llm logs --tool/-T option, closes #1013 2025-05-23 21:46:10 -07:00
Simon Willison 36477cf9e5 llm chat -c and llm -c carry forward tools, closes #1020 2025-05-23 21:10:51 -07:00
Simon Willison d2886d4692 Record which plugin a tool came from, including in DB - refs #1020 2025-05-23 15:44:12 -07:00
Simon Willison cb94047b46 Removed obsolete code I accidentally added in #1070 2025-05-23 15:22:32 -07:00
Simon Willison f6fefb3816 llm schemas list --json/--nl options, closes #1070 2025-05-23 15:17:32 -07:00
Simon Willison 5f44f89de2 Ident + tests for tool logging, closes #1042 2025-05-21 22:04:12 -07:00
Simon Willison bd2180df7d llm chat --tool and --functions (#1062)
* Tool support for llm chat, closes #1004
2025-05-20 21:30:27 -07:00
Simon Willison a31ae86c20 Refactor in prep for chat tools, refs #1004 2025-05-20 20:23:48 -07:00