文件历史

提交图

83 次代码提交

作者 SHA1 备注 提交日期
Simon Willison d7cd630ac5 Now tracking start/end index for llm.Chunk from .execute()
Also printing those out in streaming mode for non-async models, as a debug thing
2025-03-22 22:35:56 -07:00
Simon Willison 2ce2510945 Various mypy fixes relating to Union[Chunk, str] - refs #716 2025-03-22 22:01:08 -07:00
Simon Willison 236c808666 Update .excute() signature to allow str or Chunk, refs #716 2025-03-21 15:05:53 -07:00
Simon Willison 90634b98c5 Rename chunk.data to chunk.annotation
Refs https://github.com/simonw/llm/issues/716#issuecomment-2735161066
2025-03-18 19:26:52 -07:00
Simon Willison 563a4837f2 Annotations prototype, refs #716 2025-03-18 19:05:54 -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
Simon Willison f90f29dec9 Removed accidental commit of Usage class 2024-11-14 14:29:05 -08:00
Simon Willison 157b29ddeb Test for basic async conversation, refs #632 2024-11-14 14:28:17 -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 a7eedd1d2e mypy fix, refs #601
Test / test (macos-latest, >=2.0.0, 3.10) (push) Has been cancelled
Test / test (macos-latest, >=2.0.0, 3.11) (push) Has been cancelled
Test / test (macos-latest, >=2.0.0, 3.12) (push) Has been cancelled
Test / test (macos-latest, >=2.0.0, 3.13) (push) Has been cancelled
Test / test (macos-latest, >=2.0.0, 3.9) (push) Has been cancelled
Test / test (ubuntu-latest, ==1.10.2, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, ==1.10.2, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, ==1.10.2, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, ==1.10.2, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, ==1.10.2, 3.9) (push) Has been cancelled
Test / test (ubuntu-latest, >=2.0.0, 3.10) (push) Has been cancelled
Test / test (ubuntu-latest, >=2.0.0, 3.11) (push) Has been cancelled
Test / test (ubuntu-latest, >=2.0.0, 3.12) (push) Has been cancelled
Test / test (ubuntu-latest, >=2.0.0, 3.13) (push) Has been cancelled
Test / test (ubuntu-latest, >=2.0.0, 3.9) (push) Has been cancelled
Test / test (windows-latest, ==1.10.2, 3.10) (push) Has been cancelled
Test / test (windows-latest, ==1.10.2, 3.11) (push) Has been cancelled
Test / test (windows-latest, ==1.10.2, 3.12) (push) Has been cancelled
Test / test (windows-latest, ==1.10.2, 3.13) (push) Has been cancelled
Test / test (windows-latest, ==1.10.2, 3.9) (push) Has been cancelled
Test / test (windows-latest, >=2.0.0, 3.10) (push) Has been cancelled
Test / test (windows-latest, >=2.0.0, 3.11) (push) Has been cancelled
Test / test (macos-latest, ==1.10.2, 3.10) (push) Has been cancelled
Test / test (macos-latest, ==1.10.2, 3.11) (push) Has been cancelled
Test / test (macos-latest, ==1.10.2, 3.12) (push) Has been cancelled
Test / test (macos-latest, ==1.10.2, 3.13) (push) Has been cancelled
Test / test (macos-latest, ==1.10.2, 3.9) (push) Has been cancelled
Test / test (windows-latest, >=2.0.0, 3.12) (push) Has been cancelled
Test / test (windows-latest, >=2.0.0, 3.13) (push) Has been cancelled
Test / test (windows-latest, >=2.0.0, 3.9) (push) Has been cancelled
2024-11-01 14:21:01 -07:00
Simon Willison 122265a3d2 Fix for chat continuation in llm chat, refs #601 2024-11-01 14:17:25 -07:00
Simon Willison be2953e6ab Ruff and mypy fixes 2024-10-28 15:41:34 -07:00
Simon Willison 570a3eccae Python attachment documentation, plus fixed a mimetype detection bug
Refs #587
2024-10-28 15:41:34 -07:00
Simon Willison 286cf9fcd9 attachments= keyword argument, tests pass again - refs #587 2024-10-28 15:41:34 -07:00
Simon Willison 1126393ba1 Docs for writing models that accept attachments, 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
Simon Willison c0fe719df6 Store prompt attachments in attachments and prompt_attachments tables
Refs https://github.com/simonw/llm/issues/587#issuecomment-2439791231
2024-10-28 15:41:34 -07:00
Simon Willison 6df00f92ff First working prototype of new attachments feature, refs #587 2024-10-28 15:41:34 -07:00
Simon Willison 0a8fd77b26 Fix for mypy error, closes #491
This is why tests failed for #490
2024-05-13 13:00:03 -07:00
Simon Willison b9478e6a17 batch_size= argument to embed_multi(), refs #273 2023-09-13 16:24:04 -07:00
Simon Willison f54f2c659d response.__str__ method, closes #268 2023-09-12 10:36:29 -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 e49c816e18 Drop llm.EmbeddingModel.embedding_size property, closes #208 2023-09-02 08:45:17 -07:00
Simon Willison ec15707588 next(iter(...)), refs #200 2023-08-31 22:55:58 -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 dff36f0edc Change of policy: keys.json over-rides environment variables, closes #158 2023-08-20 23:27:21 -07:00
Simon Willison 14a91efbad Fixes for Pydantic 1, including matrix test - refs #169
Also refs #147
2023-08-19 20:59:30 -07:00
Chris Mungall 740a8e8344 Allow for use of Pydantic v1 as well as v2. (#147)
* Allow for use of Pydantic v1 as well as v2.

Use v1-style configuration. While this is officially
deprecated (https://docs.pydantic.dev/latest/usage/model_config/),
it is supported by v2. I would assume this support will remain
for a while, this will help ease the transition to v2
2023-08-19 20:50:59 -07:00
Simon Willison cb41409e2b conversation_name should not have newlines, closes #110 2023-07-15 21:28:35 -07:00
Simon Willison 19ba1a3099 Improvements to Response.fake() plus __repr__ for some classes 2023-07-11 15:14:52 -07:00
Simon Willison abfc9c69dc Response.fake() method
I'm using this in https://github.com/simonw/llm-gpt4all/issues/4
2023-07-11 11:08:15 -07:00