Commit graph

111 commits

Author SHA1 Message Date
Simon Willison
3cb875fa3d
Async tool support (#1063)
* Sync models can now call async tools, refs #987
* Test for async tool functions in sync context, refs #987
* Test for asyncio tools, plus test that they run in parallel
* Docs for async tool usage
2025-05-21 21:42:19 -07:00
Simon Willison
ad7dc2ef71 Enable vision for o3 and o4-mini, closes #1037 2025-05-15 10:22:13 -04:00
Simon Willison
bed617cd62 Enable tools for o3, o3-mini, o4-mini, refs #988 2025-05-13 17:19:30 -07:00
Simon Willison
88b806ae1a Got multi-tool OpenAI chat working, in no-stream mode too
Refs #1017, #1019
2025-05-13 17:19:30 -07:00
Simon Willison
0ff24b34c4 dict() is now model_dump() 2025-05-13 17:19:30 -07:00
Simon Willison
f994196b32 tool_calls_or_raise()
Refs #992, #998, #999
2025-05-13 17:19:30 -07:00
Simon Willison
7dbf0b8586 Got a tool call to run through OpenAI
Refs https://github.com/simonw/llm/issues/937#issuecomment-2870434157
2025-05-13 17:19:30 -07:00
Simon Willison
c990578934 ToolCall.tool_call_id property, refs #937 2025-05-13 17:19:30 -07:00
Simon Willison
7bc2f78156 Capture tool calls from OpenAI streaming sync responses
Refs https://github.com/simonw/llm/issues/988#issuecomment-2869079084
2025-05-13 17:19:30 -07:00
Simon Willison
84ab4cd409 supports_tools Model property, Tool.function(..., name=) option
Refs https://github.com/simonw/llm/issues/935#issuecomment-2869042481
2025-05-13 17:19:30 -07:00
Simon Willison
8e68c5e2d9 o4-mini, closes #976 2025-05-04 16:04:28 -07:00
Kevin Burke
5d0a2bba59
llm/default_plugins: add o3 model (#945)
* llm/default_plugins: add o3 model

This is the newest model released by OpenAI and is available through
the API.

* Ran cog

---------

Co-authored-by: Simon Willison <swillison@gmail.com>
2025-05-04 16:01:55 -07:00
Abizer Lokhandwala
0b37123a38
Add GPT-4.1 model family to default OpenAI plugin (#965)
* openai: add gpt-4.1 models
* Refactor and run cog

---------

Co-authored-by: Simon Willison <swillison@gmail.com>
2025-05-04 10:27:12 -07:00
giuli007
51db7afddb
Support vision and audio for extra-openai-models.yaml (#843)
Add a vision option to enable OpenAI-compatible
models to receive image and audio attachments
2025-03-22 16:14:18 -07:00
adaitche
de87d37c28
Add supports_schema to extra-openai-models (#819)
Recently support for structured output was added. But custom
OpenAI-compatible models didn't support the `supports_schema` property
in the config file `extra-openai-models.yaml`.
2025-03-21 16:59:34 -07:00
Simon Willison
2cbe46304b PDF support for vision models, refs #834 2025-03-18 15:38:28 -07:00
Simon Willison
efe265137d Only some OpenAI models support schemas, closes #794 2025-02-27 15:02:39 -08:00
Simon Willison
6bec92fd78 Assign gpt-4.5 default alias, refs #795 2025-02-27 14:51:09 -08:00
Simon Willison
801b08bf40 gpt-4.5-preview and gpt-4.5-preview-2025-02-27, refs #795 2025-02-27 12:25:04 -08:00
Kasper Primdal Lauritzen
6cb16a1d1a
Allow "reasoning" for extra-openai-models.yaml (#766)
* Allow "reasoning" for extra-openai-models.yaml

Currently you get an error when trying to use `-o reasoning_effort high` with a model that has been defined in `extra-openai-models.yaml`. 
This allows a `reasoning` field.

* Mention reasoning: true in other OpenAI models docs

---------

Co-authored-by: Simon Willison <swillison@gmail.com>
2025-02-26 21:50:14 -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
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
b331b1e674 OpenAI model chatgpt-4o-latest, closes #752 2025-02-15 17:45:09 -08:00
Simon Willison
eb0e1e761b o3-mini and reasoning_effort option, refs #728 2025-01-31 12:14:02 -08:00
Simon Willison
57d3baac42 Update embedding model names in docs, refs #654
Also ran Black.
2025-01-22 20:35:17 -08:00
web-sst
6f7ea406bf
Register full embedding model names (#654)
Provide backward compatible aliases.
This makes available the same model names that ttok uses.
2025-01-22 20:14:03 -08:00
Simon Willison
38a7366d8e o1 cannot stream
https://github.com/simonw/llm/issues/676#issuecomment-2584932453
2025-01-10 16:03:09 -08:00
Simon Willison
6baf1f7d83 o1
Closes #676
2025-01-10 15:57:06 -08:00
Simon Willison
67d4a99645 llm prompt -x/--extract option, closes #681 2024-12-19 06:40:05 -08:00
Simon Willison
6305b86026 gpt-4o-mini-audio-preview, closes #677 2024-12-17 20:28:57 -08:00
Simon Willison
8898584ba6 New OpenAI audio models, closes #677 2024-12-17 11:14:42 -08:00
Simon Willison
aa25ad1d54 o1-preview and o1-mini can stream now
Refs https://github.com/simonw/llm/issues/676#issuecomment-2549328154
2024-12-17 10:53:15 -08:00
Simon Willison
571f4b2a4d
Fix for UTC warnings
Closes #672
2024-12-12 14:57:23 -08:00
Simon Willison
491dd9b437 Removed accidental comment 2024-12-05 13:45:50 -08:00
Simon Willison
b6be09aa28 Fix get_models() and get_async_models() duplicates bug
Closes #667, refs #640
2024-12-05 13:44:07 -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
cf172cc70a response.text_or_raise() workaround
Closes https://github.com/simonw/llm/issues/632
2024-11-14 15:08:41 -08:00
Simon Willison
ba75c674cb
llm.get_async_model(), llm.AsyncModel base class and OpenAI async models (#613)
- 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>
2024-11-13 17:51:00 -08:00
Simon Willison
7520671176 audio/wav not audio/wave, refs #603 2024-11-12 21:43:07 -08:00
Simon Willison
3352eb9f57 Serialize usage to JSON properly, closes #614 2024-11-06 03:27:25 -08:00
Chris Mungall
3b2e5263a3
Allow passing of can_stream in openai_models.py (#600)
* Allow passing of can_stream in openai_models.py

Fixes #599 

* Only set can_stream: false if it is false

Refs https://github.com/simonw/llm/pull/600#issuecomment-2458825866

* Docs for can_stream: false

---------

Co-authored-by: Simon Willison <swillison@gmail.com>
2024-11-05 23:04:13 -08:00
Simon Willison
12df1a3b2a Show attachment types in llm models --options, closes #612 2024-11-05 22:49:26 -08:00
Simon Willison
0cc4072bcd Support attachments without prompts, closes #611 2024-11-05 21:27:18 -08:00
Simon Willison
336ab1013d gpt-4o-audio-preview audio input, refs #608 2024-11-05 21:08:52 -08:00
Simon Willison
389acdf52c Track usage on OpenAI stream requests, closes #591 2024-10-28 17:40:40 -07:00
Simon Willison
a68af9c8e6 Don't redact non-data URLs for OpenAI models
Refs #587
2024-10-28 15:41:34 -07:00
Simon Willison
cd722f653b Redact base64 data from _prompt_json, refs #587 2024-10-28 15:41:34 -07:00
Simon Willison
dff5b456fd Got llm --continue to work with images, refs #587 2024-10-28 15:41:34 -07:00