Commit graph

31 commits

Author SHA1 Message Date
Simon Willison
7e819c2ffa Implemented --schema-multi, closes #791 2025-02-27 10:12:21 -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
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
67d4a99645 llm prompt -x/--extract option, closes #681 2024-12-19 06:40:05 -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
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
5d1d723d4b Special case treat audio/wave as audio/wav, closes #603 2024-11-07 17:13:54 -08:00
Simon Willison
39d61d433a Automated tests for attachments, refs #587 2024-10-28 19:21:11 -07:00
Simon Willison
a83421607a Switch default model to gpt-4o-mini (from gpt-3.5-turbo), refs #536 2024-07-18 11:57:19 -07:00
Simon Willison
214fcaaf86
Upgrade to run against OpenAI >= 1.0
* strategy: fail-fast: false - to help see all errors
* Apply latest Black

Refs #325
2024-01-25 22:00:44 -08:00
Simon Willison
fcff36c6bc completion: true to register completion models, refs #284 2023-09-18 22:17:26 -07:00
Simon Willison
4fea46113f logprobs support for OpenAI completion models, refs #284 2023-09-18 22:04:28 -07:00
Simon Willison
2b504279d9 Test for OpenAI chat streaming, closes #287 2023-09-18 21:27:36 -07:00
Simon Willison
4d46ebaa32 OpenAI completion models including gpt-3.5-turbo-instruct, refs #284 2023-09-18 18:34:32 -07:00
Simon Willison
52cec1304b
Binary embeddings (#254)
* Binary embeddings support, refs #253
* Write binary content to content_blob, with tests - refs #253
* supports_text and supports_binary embedding validation, refs #253
2023-09-11 18:58:44 -07:00
Simon Willison
ae7f4f6de7 llm chat -o/--option - refs #244 2023-09-10 11:14:28 -07:00
Simon Willison
5495112d9f Initial tests for llm chat, refs #231 2023-09-04 23:36:25 -07:00
Simon Willison
3bf781fba2 Duplicate content is only embedded once, closes #217 2023-09-03 17:39:11 -07:00
Simon Willison
213e0b0c75 embed-db delete-collection command and .delete() method, closes #219 2023-09-03 12:55:48 -07:00
Simon Willison
51488c579b Collection now defaults to in-memory DB, closes #213 2023-09-02 15:43:20 -07:00
Simon Willison
4be89facb5 Fixed and finished llm similar command, closes #190 2023-09-01 19:01:16 -07:00
Simon Willison
3ee92152e8 Error conditions for 'llm similar', refs #190 2023-09-01 18:31:59 -07:00
Simon Willison
817aff8bae Embeddings now happen in batches, closes #200 2023-08-31 22:27:06 -07:00
Simon Willison
77cf56e54a
Initial CLI support and plugin hook for embeddings, refs #185
* Embeddings plugin hook + OpenAI implementation
* llm.get_embedding_model(name) function
* llm embed command, for returning embeddings or saving them to SQLite
* Tests using an EmbedDemo embedding model
* llm embed-models list and emeb-models default commands
* llm embed-db path and llm embed-db collections commands
2023-08-27 22:24:10 -07:00
Simon Willison
e2072f7044 Ability to register additional OpenAI-compatible models
Closes #107, closes #106
2023-07-15 10:01:03 -07:00
Simon Willison
9a180e65a8 llm models default command, plus refactored env variables
Closes #76
Closes #31
2023-07-01 14:01:29 -07:00
Simon Willison
a396950f79 Initial plugin framework and register_commands(cli) hook, refs #49 2023-06-17 17:42:13 +01:00
Simon Willison
144ffc3f6b Prompt templates
Closes #23
2023-06-17 08:40:46 +01:00
Simon Willison
8308fe5cbf Store debug info, closes #34 2023-06-16 08:51:56 +01:00
Simon Willison
1bb04c416c Move logs.db to user_data_dir, refs #27 2023-06-15 19:59:08 +01:00