文件历史

110 次代码提交

作者 SHA1 备注 提交日期
Simon Willison a8740b066c Fixed remaining mypy problems, refs #1023
Refs https://github.com/simonw/llm/pull/996#issuecomment-2878191352
2025-05-13 16:47:59 -07:00
Simon Willison cc99984259 Fix for TypeError: 'coroutine' object is not iterable 2025-05-13 16:39:20 -07:00
Simon Willison 7a32d0daec AsyncModel.chain() raises NotImplementedError, closes #1021 2025-05-13 16:31:17 -07:00
Simon Willison 027ec69ed5 Guard against chunk=None from models
Bug that I encountered while working on #1019
2025-05-13 12:12:24 -07:00
Simon Willison 104ef266cb Upgrade condense-json
Refs https://github.com/simonw/llm/issues/1003#issuecomment-2873322525
Refs https://github.com/simonw/condense-json/issues/5
2025-05-13 10:10:25 -07:00
Simon Willison 1ea8f6eb24 ChainResponse.log_to_db() method and test, refs #1017, #1003 2025-05-13 09:53:40 -07:00
Simon Willison 0bdefd10c9 First test for tools, plus vcr+syrupy, refs #1017 2025-05-13 08:03:01 -07:00
Simon Willison 0273e0ff69 Removed obsolete details() method, closes #1007 2025-05-12 21:02:02 -07:00
Simon Willison 9e7d463ef4 Initial implementation of --td and --ta, refs #1005
Uses new mechanism from #1007
2025-05-12 20:57:50 -07:00
Simon Willison 95b8150b5b New response.excute_tool_calls(), refs #1007 2025-05-12 20:47:15 -07:00
Simon Willison 4d64410ca3 Load tool stuff from database, refs #1010 2025-05-12 19:54:32 -07:00
Simon Willison 0c85b30bdf Ensure all responses have a ULID 2025-05-12 19:52:33 -07:00
Simon Willison 2cee1d2946 tool_calls_or_raise()
Refs #992, #998, #999
2025-05-12 11:46:16 -07:00
Simon Willison e1b06d31f7 Log tool stuff to the database, refs #1003 2025-05-12 10:02:19 -07:00
Simon Willison 60861eddc3 First working prototype of llm -T toolname
Refs https://github.com/simonw/llm/issues/990#issuecomment-2870630946
2025-05-11 20:09:31 -07:00
Simon Willison 9263f37658 model.chain() method, tools=[func1, func2]
Also fixed mypy errors, but had to drop AsyncResponse for the moment.

Refs https://github.com/simonw/llm/issues/937#issuecomment-2870479021
2025-05-11 18:53:42 -07:00
Simon Willison dd95f23e0c .chain().details() debug method
https://github.com/simonw/llm/issues/937#issuecomment-2870465951
2025-05-11 18:28:55 -07:00
Simon Willison 8f9ca0b4b7 Got a tool call to run through OpenAI
Refs https://github.com/simonw/llm/issues/937#issuecomment-2870434157
2025-05-11 18:01:28 -07:00
Simon Willison dae4ad6bcc Enforce chain limit of 5
Refs https://github.com/simonw/llm/issues/937#issuecomment-2870390330
2025-05-11 17:23:43 -07:00
Simon Willison 5e2190162b Initial Conversation.chain() and ChainResponse
Refs https://github.com/simonw/llm/issues/937#issuecomment-2870365809
2025-05-11 17:14:57 -07:00
Simon Willison 2b082e6062 ToolCall.tool_call_id property, refs #937 2025-05-11 17:14:38 -07:00
Simon Willison d58ad5f65b prompt.tools and prompt.tool_results no longer optional
They will always be at least an empty list
2025-05-10 15:10:14 -07:00
Simon Willison 1b0dd34a32 Prompt.tool_results property
Refs https://github.com/simonw/llm/issues/937#issuecomment-2869124983
2025-05-10 12:36:30 -07:00
Simon Willison 614941dbe5 ToolResult dataclass
Refs https://github.com/simonw/llm/issues/937#issuecomment-2869123620
2025-05-10 12:33:29 -07:00
Simon Willison ab9cea9858 Dropped Tool.output_schema
Refs https://github.com/simonw/llm/issues/935#issuecomment-2869120546
2025-05-10 12:23:35 -07:00
Simon Willison ca4a08e90b Stash function in tool.implementation
Refs https://github.com/simonw/llm/issues/935#issuecomment-2869084490
2025-05-10 11:54:40 -07:00
Simon Willison f8cd7be600 response.tool_calls() methods
Refs https://github.com/simonw/llm/issues/936#issuecomment-2869082672
2025-05-10 11:38:51 -07:00
Simon Willison d2da482111 Response.add_tool_call() method and ToolCall class
Refs https://github.com/simonw/llm/issues/936#issuecomment-2869064678
2025-05-10 11:06:38 -07:00
Simon Willison 0d94576706 supports_tools Model property, Tool.function(..., name=) option
Refs https://github.com/simonw/llm/issues/935#issuecomment-2869042481
2025-05-10 10:29:23 -07:00
Simon Willison 08054a022d Pass tools around a bit
Refs https://github.com/simonw/llm/issues/935#issuecomment-2869032532
2025-05-10 10:19:30 -07:00
Simon Willison 86ccce4e5e WIP Tool definition class
Refs https://github.com/simonw/llm/issues/935#issuecomment-2869002227
2025-05-10 10:01:50 -07:00
Simon Willison f740a5cbbd Fragments (#859)
* WIP fragments: schema plus reading but not yet writing, refs #617
* Unique index on fragments.alias, refs #617
* Fragments are now persisted, added basic CLI commands
* Fragment aliases work now, refs #617
* Improved help for -f/--fragment
* Support fragment hash as well
* Documentation for fragments
* Better non-JSON display of llm fragments list
* llm fragments -q search option
* _truncate_string is now truncate_string
* Use condense_json to avoid duplicate data in JSON in DB, refs #617
* Follow up to 3 redirects for fragments
* Python API docs for fragments= and system_fragments=
* Fragment aliases cannot contain a : - this is to ensure we can add custom fragment loaders later on, refs https://github.com/simonw/llm/pull/859#issuecomment-2761534692
* Use template fragments when running prompts
* llm fragments show command plus llm fragments group tests
* Tests for fragments family of commands
* Test for --save with fragments
* Add fragments tables to docs/logging.md
* Slightly better llm fragments --help
* Handle fragments in past conversations correctly
* Hint at llm prompt --help in llm --help, closes #868
* llm logs -f filter plus show fragments in llm logs --json
* Include prompt and system fragments in llm logs -s
* llm logs markdown fragment output and tests, refs #617
2025-04-05 17:22:37 -07:00
Simon Willison f35ac31c21 llm logs --schema, --data, --data-array and --data-key options (#785)
* llm logs --schema option, refs #782
* --data and --data-array and --data-key options, refs #782
* Tests for llm logs --schema options, refs #785
* Also implemented --schema ID lookup, refs #780
* Using --data-key implies --data
* Docs for llm logs --schema and --data etc
2025-02-26 21:51:08 -08:00
Simon Willison 9922d5bb6a model.prompt(prompt= is now optional, closes #784 2025-02-26 19:31:38 -08:00
Simon Willison 62c90dd472 llm prompt --schema X option and model.prompt(..., schema=) parameter (#777)
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
2025-02-26 16:58:28 -08:00
Simon Willison 849c65fe9d Upgrade to Pydantic v2 (#775)
* Upgrade to Pydantic v2
* Stop testing against Pydantic v1

Closes #520
2025-02-26 10:05:54 -08:00
Simon Willison 7bf1ea665e Made load_conversation() async_ aware, closes #742 2025-02-16 20:19:38 -08:00
Simon Willison 24b250506b Better __repr__ and __str__ for conversation and model
Inspired by work on #752
2025-02-16 15:45:08 -08:00
Simon Willison 6c6b100f3e KeyModel and AsyncKeyModel classes for models that taken keys (#753)
* 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
2025-02-16 14:38:51 -08:00
Simon Willison 20c18a716d -q multiple option for llm models and llm embed-models
Refs #748
2025-02-13 15:35:18 -08:00
Simon Willison 73043ec406 Fixed mypy complaint 2025-01-10 16:05:29 -08:00
Simon Willison b452effa09 llm models -q/--query option, closes #700 2025-01-09 11:37:33 -08:00
Simon Willison 571f4b2a4d Fix for UTC warnings
Closes #672
2024-12-12 14:57:23 -08:00
Simon Willison f9af563df5 response.on_done() mechanism, closes #653 2024-12-01 15:47:23 -08:00
Simon Willison 8a7b0c4f5d response.usage() and await aresponse.usage(), closes #644 2024-11-19 21:25:37 -08:00
Simon Willison cfb10f4afd Log input tokens, output tokens and token details (#642)
* Store input_tokens, output_tokens, token_details on Response, closes #610
* llm prompt -u/--usage option
* llm logs -u/--usage option
* Docs on tracking token usage in plugins
* OpenAI default plugin logs usage
2024-11-19 20:21:59 -08:00
Simon Willison 4a059d722b Log --async responses to DB, closes #641
Refs #507
2024-11-19 18:11:52 -08:00
Simon Willison 0fec9746f4 text_or_raise() on sync Response too
Refs #632
2024-11-17 12:20:20 -08:00
Simon Willison cf172cc70a response.text_or_raise() workaround
Closes https://github.com/simonw/llm/issues/632
2024-11-14 15:08:41 -08:00
Simon Willison 3b6e73445c Better __repr__ for Response and AsyncResponse 2024-11-14 14:42:40 -08:00