dot-inference 4.1.0__tar.gz → 4.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dot_inference-4.1.0 → dot_inference-4.2.0}/CHANGELOG.md +57 -3
- {dot_inference-4.1.0 → dot_inference-4.2.0}/PKG-INFO +42 -5
- {dot_inference-4.1.0 → dot_inference-4.2.0}/README.md +41 -4
- {dot_inference-4.1.0 → dot_inference-4.2.0}/docs/PUBLISHING.md +3 -2
- dot_inference-4.2.0/docs/VERSIONING.md +164 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/pyproject.toml +1 -1
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/__init__.py +3 -1
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_client.py +4 -4
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_llm_registry.py +55 -23
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_local_check.py +17 -2
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_openai_compat.py +15 -2
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/models.yaml +96 -11
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/settings.py +3 -1
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_factories.py +14 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_llm_registry.py +78 -4
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_local_check.py +21 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_openai_compat.py +59 -1
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_routes.py +25 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/uv.lock +2 -2
- dot_inference-4.1.0/docs/VERSIONING.md +0 -120
- {dot_inference-4.1.0 → dot_inference-4.2.0}/.env.template +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/.gitignore +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/.gitlab-ci.yml +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/.pre-commit-config.yaml +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/.python-version +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/AUTHORS.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/CONTRIBUTING.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/LICENSE.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/docs/ARCHITECTURE.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/docs/DEVELOPMENT.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/docs/provider-quirks/openrouter-errors.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/docs/provider-quirks/strict-schemas.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/docs/provider-quirks/tool-choice.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/examples/demo.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/examples/demo_streaming.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/examples/doc_stream.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/scripts/provider-quirks/tool-choice/mistral_compare.sh +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/scripts/provider-quirks/tool-choice/mistral_runaway.sh +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/scripts/provider-quirks/tool-choice/openrouter_compare.sh +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/scripts/provider-quirks/tool-choice/openrouter_runaway.sh +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/scripts/test_all_models.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/README.md +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_cost_tracker.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_mistral_compat.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_rate_limit.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_retry.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_routes.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_strict_schema.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_sync.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/_types.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/src/dot_inference/mock.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/__init__.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_constrained_live.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_cost_tracker.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_images.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_mistral_compat.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_mistral_live.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_rate_limit.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_retry.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_settings.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_strict_schema.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_sync.py +0 -0
- {dot_inference-4.1.0 → dot_inference-4.2.0}/tests/test_types.py +0 -0
|
@@ -2,11 +2,64 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|
6
|
-
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
6
|
+
Versions follow [docs/VERSIONING.md](docs/VERSIONING.md): while the package is
|
|
7
|
+
in alpha, a minor release may contain breaking changes, each marked **Breaking**.
|
|
7
8
|
|
|
8
9
|
## [Unreleased]
|
|
9
10
|
|
|
11
|
+
## [4.2.0] - 2026-11-12
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `reasoning_chat_template_kwargs`, per provider in the registry
|
|
16
|
+
(`ProviderModelConfig`): for a self-hosted model whose chat template does not
|
|
17
|
+
read `reasoning_effort`, the `chat_template_kwargs` each effort stands for.
|
|
18
|
+
The client sends them in place of `reasoning_effort`; `chat_template_kwargs`
|
|
19
|
+
passed in `extra_body` win, one variable at a time.
|
|
20
|
+
- `LocalEndpointCheck.context_window`: the context window the local server
|
|
21
|
+
serves the model with (`max_model_len`, as vLLM and SGLang report it), `None`
|
|
22
|
+
when the server does not say. A self-hosted server is often started with less
|
|
23
|
+
than the model's limit.
|
|
24
|
+
- `get_max_context_window(model)`: the model's limit, as the registry declares
|
|
25
|
+
it.
|
|
26
|
+
- `nvidia/nemotron-3.5-super-vl-120b-a12b-local`: Nemotron 3.5 Super VL served
|
|
27
|
+
by vLLM. Its reasoning efforts are `none`, `medium` and `high` (the levels of
|
|
28
|
+
its chat template); with no effort chosen, the server's default applies.
|
|
29
|
+
- `lightonai/lightonocr-3-0.8b-local`: the LightOnOCR-3 OCR model served by
|
|
30
|
+
vLLM.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- Versioning: while the package is in alpha, breaking changes are released in
|
|
35
|
+
minor versions, each marked **Breaking** here, and no longer need a major.
|
|
36
|
+
Patch releases never break. A range such as `>=4,<5` therefore no longer rules
|
|
37
|
+
out a breaking change: see [docs/VERSIONING.md](docs/VERSIONING.md).
|
|
38
|
+
- **Breaking:** no reasoning effort is sent unless one is chosen.
|
|
39
|
+
`GenerationSettings.reasoning_effort` (`DOTI_GENERATION__REASONING_EFFORT`)
|
|
40
|
+
defaults to `None`, no longer to `medium`: a call that names no effort is left
|
|
41
|
+
to the provider's default, or the local server's, unless the model's registry
|
|
42
|
+
entry sets one (`default_reasoning_effort`). `medium` did not mean the same
|
|
43
|
+
thing from one model to the next, and overrode each provider's own default.
|
|
44
|
+
Set `DOTI_GENERATION__REASONING_EFFORT=medium` to keep sending it.
|
|
45
|
+
- **Breaking:** a reasoning model declares the efforts it accepts.
|
|
46
|
+
`reasoning_effort_options` is required with `supports_reasoning`, in a
|
|
47
|
+
`DOTI_CUSTOM_MODELS` file and in `ModelConfig`, which raise `ValueError`
|
|
48
|
+
without it; `[low, medium, high]` is no longer assumed. The built-in entries
|
|
49
|
+
that relied on it now list efforts that OpenRouter's model list gives them
|
|
50
|
+
(`reasoning.supported_efforts`).
|
|
51
|
+
- **Breaking:** `nvidia/nemotron-3-super-120b-a12b` accepts `none`, `low` and
|
|
52
|
+
`medium`, no longer `high`, which OpenRouter does not list for it.
|
|
53
|
+
- **Breaking:** `google/gemma-4-31b-it`, `minimax/minimax-m2.7`,
|
|
54
|
+
`qwen/qwen3.5-9b`, `qwen/qwen3.5-27b` and `anthropic/claude-haiku-4.5` no
|
|
55
|
+
longer take a reasoning effort (`supports_reasoning: false`): they reason, but
|
|
56
|
+
OpenRouter gives them no effort to choose, and the one sent made no difference.
|
|
57
|
+
|
|
58
|
+
### Deprecated
|
|
59
|
+
|
|
60
|
+
- `get_context_window(model)`: use `get_max_context_window(model)`, the same
|
|
61
|
+
value under a name that says what it is. Removed in 5.0.
|
|
62
|
+
|
|
10
63
|
## [4.1.0] - 2026-11-09
|
|
11
64
|
|
|
12
65
|
### Added
|
|
@@ -242,7 +295,8 @@ this release.
|
|
|
242
295
|
- `LLMCallable` and `EmbeddingCallable` return a `Coroutine` rather than the
|
|
243
296
|
looser `Awaitable`, matching what `asyncio.run_coroutine_threadsafe` accepts.
|
|
244
297
|
|
|
245
|
-
[Unreleased]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/compare/v4.
|
|
298
|
+
[Unreleased]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/compare/v4.2.0...main
|
|
299
|
+
[4.2.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.2.0
|
|
246
300
|
[4.1.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.1.0
|
|
247
301
|
[4.0.0]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v4.0.0
|
|
248
302
|
[3.1.1]: https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference/-/tags/v3.1.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: dot-inference
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.2.0
|
|
4
4
|
Summary: Unified async Python library for LLM inference and embeddings across multiple providers
|
|
5
5
|
Project-URL: Homepage, https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference
|
|
6
6
|
Project-URL: Repository, https://gitlab.com/deepika6190303/deepika-open-toolbox/dot-inference
|
|
@@ -156,6 +156,13 @@ client = get_llm_client(
|
|
|
156
156
|
response = asyncio.run(client.call([Message(role=Role.USER, content="Solve this step by step...")]))
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
+
When no effort is chosen, none is sent: the provider, or the local server,
|
|
160
|
+
applies its own default. A model's registry entry may set one
|
|
161
|
+
(`default_reasoning_effort`), and so may the settings, for every model
|
|
162
|
+
(`DOTI_GENERATION__REASONING_EFFORT`). An effort name is not shared from one
|
|
163
|
+
model to the next: `allowed_reasoning_efforts(model)` returns those a model
|
|
164
|
+
accepts, and another one raises a `ValueError`.
|
|
165
|
+
|
|
159
166
|
### Structured output
|
|
160
167
|
|
|
161
168
|
```python
|
|
@@ -399,12 +406,40 @@ served = (await list_served_models(base_url))[0]
|
|
|
399
406
|
register_model(ModelConfig(
|
|
400
407
|
model_id=served,
|
|
401
408
|
supports_reasoning=True,
|
|
409
|
+
reasoning_effort_options=["low", "medium", "high"], # those the served model accepts
|
|
402
410
|
supports_vision=True, # if the served model reads images
|
|
403
411
|
default_provider="local",
|
|
404
412
|
providers={"local": ProviderModelConfig(api_model_name=served)},
|
|
405
413
|
))
|
|
406
414
|
```
|
|
407
415
|
|
|
416
|
+
Some self-hosted models do not read `reasoning_effort`: their chat template has
|
|
417
|
+
its own variables (`enable_thinking`…), which vLLM and SGLang take as
|
|
418
|
+
`chat_template_kwargs`. The registry then declares, for the `local` provider,
|
|
419
|
+
the variables each effort stands for (`reasoning_chat_template_kwargs`), and
|
|
420
|
+
the client sends those in place of `reasoning_effort`. The caller chooses an
|
|
421
|
+
effort as for any other model:
|
|
422
|
+
|
|
423
|
+
```python
|
|
424
|
+
client = get_llm_client(settings, model="nvidia/nemotron-3.5-super-vl-120b-a12b-local")
|
|
425
|
+
await client.call(messages, reasoning_effort="none") # sends enable_thinking: false
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
`chat_template_kwargs` passed in `extra_body` win over those of the effort, one
|
|
429
|
+
variable at a time.
|
|
430
|
+
|
|
431
|
+
The registry's `context_window` is the model's limit
|
|
432
|
+
(`get_max_context_window(model)`). A self-hosted server is started with the
|
|
433
|
+
window its hardware holds, often a smaller one, and vLLM and SGLang report it:
|
|
434
|
+
`check_local_endpoint(model)` returns it as `.context_window` (`None` when the
|
|
435
|
+
server does not say). Size prompts from that one:
|
|
436
|
+
|
|
437
|
+
```python
|
|
438
|
+
model = "nvidia/nemotron-3.5-super-vl-120b-a12b-local"
|
|
439
|
+
check = await check_local_endpoint(model)
|
|
440
|
+
window = (check and check.context_window) or get_max_context_window(model)
|
|
441
|
+
```
|
|
442
|
+
|
|
408
443
|
## Testing without API calls
|
|
409
444
|
|
|
410
445
|
```python
|
|
@@ -416,12 +451,14 @@ your Pydantic schema — so tests never reach a provider.
|
|
|
416
451
|
|
|
417
452
|
## Stability
|
|
418
453
|
|
|
419
|
-
`dot-inference`
|
|
420
|
-
|
|
421
|
-
|
|
454
|
+
`dot-inference` is in alpha, and its API still moves. A patch release only
|
|
455
|
+
fixes; a minor release may break, and says so under **Breaking** in the
|
|
456
|
+
[changelog](CHANGELOG.md); a major is kept for a redesign. Everything exported
|
|
457
|
+
from the top-level package is covered, anything underscore-prefixed is internal
|
|
458
|
+
and may change in any release.
|
|
422
459
|
|
|
423
460
|
```toml
|
|
424
|
-
dependencies = ["dot-inference>=
|
|
461
|
+
dependencies = ["dot-inference>=4.2,<4.3"] # patches only
|
|
425
462
|
```
|
|
426
463
|
|
|
427
464
|
See [docs/VERSIONING.md](docs/VERSIONING.md) for the full policy.
|
|
@@ -129,6 +129,13 @@ client = get_llm_client(
|
|
|
129
129
|
response = asyncio.run(client.call([Message(role=Role.USER, content="Solve this step by step...")]))
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
When no effort is chosen, none is sent: the provider, or the local server,
|
|
133
|
+
applies its own default. A model's registry entry may set one
|
|
134
|
+
(`default_reasoning_effort`), and so may the settings, for every model
|
|
135
|
+
(`DOTI_GENERATION__REASONING_EFFORT`). An effort name is not shared from one
|
|
136
|
+
model to the next: `allowed_reasoning_efforts(model)` returns those a model
|
|
137
|
+
accepts, and another one raises a `ValueError`.
|
|
138
|
+
|
|
132
139
|
### Structured output
|
|
133
140
|
|
|
134
141
|
```python
|
|
@@ -372,12 +379,40 @@ served = (await list_served_models(base_url))[0]
|
|
|
372
379
|
register_model(ModelConfig(
|
|
373
380
|
model_id=served,
|
|
374
381
|
supports_reasoning=True,
|
|
382
|
+
reasoning_effort_options=["low", "medium", "high"], # those the served model accepts
|
|
375
383
|
supports_vision=True, # if the served model reads images
|
|
376
384
|
default_provider="local",
|
|
377
385
|
providers={"local": ProviderModelConfig(api_model_name=served)},
|
|
378
386
|
))
|
|
379
387
|
```
|
|
380
388
|
|
|
389
|
+
Some self-hosted models do not read `reasoning_effort`: their chat template has
|
|
390
|
+
its own variables (`enable_thinking`…), which vLLM and SGLang take as
|
|
391
|
+
`chat_template_kwargs`. The registry then declares, for the `local` provider,
|
|
392
|
+
the variables each effort stands for (`reasoning_chat_template_kwargs`), and
|
|
393
|
+
the client sends those in place of `reasoning_effort`. The caller chooses an
|
|
394
|
+
effort as for any other model:
|
|
395
|
+
|
|
396
|
+
```python
|
|
397
|
+
client = get_llm_client(settings, model="nvidia/nemotron-3.5-super-vl-120b-a12b-local")
|
|
398
|
+
await client.call(messages, reasoning_effort="none") # sends enable_thinking: false
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
`chat_template_kwargs` passed in `extra_body` win over those of the effort, one
|
|
402
|
+
variable at a time.
|
|
403
|
+
|
|
404
|
+
The registry's `context_window` is the model's limit
|
|
405
|
+
(`get_max_context_window(model)`). A self-hosted server is started with the
|
|
406
|
+
window its hardware holds, often a smaller one, and vLLM and SGLang report it:
|
|
407
|
+
`check_local_endpoint(model)` returns it as `.context_window` (`None` when the
|
|
408
|
+
server does not say). Size prompts from that one:
|
|
409
|
+
|
|
410
|
+
```python
|
|
411
|
+
model = "nvidia/nemotron-3.5-super-vl-120b-a12b-local"
|
|
412
|
+
check = await check_local_endpoint(model)
|
|
413
|
+
window = (check and check.context_window) or get_max_context_window(model)
|
|
414
|
+
```
|
|
415
|
+
|
|
381
416
|
## Testing without API calls
|
|
382
417
|
|
|
383
418
|
```python
|
|
@@ -389,12 +424,14 @@ your Pydantic schema — so tests never reach a provider.
|
|
|
389
424
|
|
|
390
425
|
## Stability
|
|
391
426
|
|
|
392
|
-
`dot-inference`
|
|
393
|
-
|
|
394
|
-
|
|
427
|
+
`dot-inference` is in alpha, and its API still moves. A patch release only
|
|
428
|
+
fixes; a minor release may break, and says so under **Breaking** in the
|
|
429
|
+
[changelog](CHANGELOG.md); a major is kept for a redesign. Everything exported
|
|
430
|
+
from the top-level package is covered, anything underscore-prefixed is internal
|
|
431
|
+
and may change in any release.
|
|
395
432
|
|
|
396
433
|
```toml
|
|
397
|
-
dependencies = ["dot-inference>=
|
|
434
|
+
dependencies = ["dot-inference>=4.2,<4.3"] # patches only
|
|
398
435
|
```
|
|
399
436
|
|
|
400
437
|
See [docs/VERSIONING.md](docs/VERSIONING.md) for the full policy.
|
|
@@ -61,8 +61,9 @@ It has to be declared once on each index, *before* the first upload.
|
|
|
61
61
|
uv version --bump major # 2.0.0 -> 3.0.0
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
Fixes go in `patch`; new features and breaking changes in `minor`, the
|
|
65
|
+
breaking ones listed as **Breaking** in the changelog; `major` is kept for a
|
|
66
|
+
redesign ([VERSIONING.md](VERSIONING.md)).
|
|
66
67
|
|
|
67
68
|
3. Commit, tag and push:
|
|
68
69
|
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Versioning and stability
|
|
2
|
+
|
|
3
|
+
`dot-inference` is in alpha (`Development Status :: 3 - Alpha` in
|
|
4
|
+
`pyproject.toml`): its API still moves. Versions are `MAJOR.MINOR.PATCH`, and
|
|
5
|
+
while the alpha lasts they mean this:
|
|
6
|
+
|
|
7
|
+
| Release | What it may contain |
|
|
8
|
+
|---|---|
|
|
9
|
+
| patch (`4.2.0` → `4.2.1`) | Fixes only. Never a breaking change. |
|
|
10
|
+
| minor (`4.2.0` → `4.3.0`) | New features, and breaking changes, each one listed as **Breaking** in the changelog with what to do about it. |
|
|
11
|
+
| major (`4.x` → `5.0.0`) | A redesign that touches most callers, or the end of the alpha. Rare. |
|
|
12
|
+
|
|
13
|
+
This is not [Semantic Versioning](https://semver.org/spec/v2.0.0.html), where
|
|
14
|
+
only a major may break: an API that moves this often would get a new major every
|
|
15
|
+
few weeks, and the number would say nothing. The release that ends the alpha is a
|
|
16
|
+
major, and from then on breaking changes are made in majors only.
|
|
17
|
+
|
|
18
|
+
## What is public
|
|
19
|
+
|
|
20
|
+
**Public API** — everything exported from the top-level package:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import dot_inference
|
|
24
|
+
dot_inference.__all__ # this, and nothing else
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Public names are covered by the rules below: they never break in a patch, and
|
|
28
|
+
never without a **Breaking** entry in the changelog.
|
|
29
|
+
|
|
30
|
+
**Internal** — everything else, including:
|
|
31
|
+
|
|
32
|
+
- any module whose name starts with an underscore (`_client.py`, `_types.py`, `_openai_compat.py`)
|
|
33
|
+
- any attribute or method starting with an underscore, even on a public class
|
|
34
|
+
(`client._model_config`)
|
|
35
|
+
- the exact wording of log messages and exception text
|
|
36
|
+
|
|
37
|
+
Internals can change in any release, including a patch. If you find yourself
|
|
38
|
+
reaching for one, open an issue — that is usually a sign something is missing
|
|
39
|
+
from the public API.
|
|
40
|
+
|
|
41
|
+
**The model registry is data, not API.** What `models.yaml` says of a model
|
|
42
|
+
(its prices, its context window, its capabilities, the reasoning efforts it
|
|
43
|
+
accepts) follows the providers, which change them without notice. A registry
|
|
44
|
+
change ships in a minor, or in a patch when it only corrects a figure. One that
|
|
45
|
+
takes something away from a model is listed as **Breaking**, with no deprecation
|
|
46
|
+
period: the provider has already made the change.
|
|
47
|
+
|
|
48
|
+
## What triggers which bump
|
|
49
|
+
|
|
50
|
+
| Change | Bump |
|
|
51
|
+
|---|---|
|
|
52
|
+
| Removing or renaming a public name | minor, **Breaking** |
|
|
53
|
+
| Removing a parameter, or making an optional one required | minor, **Breaking** |
|
|
54
|
+
| Narrowing an accepted type, or widening a return type | minor, **Breaking** |
|
|
55
|
+
| Changing documented behaviour in a way existing code would notice | minor, **Breaking** |
|
|
56
|
+
| Removing a deprecated name after its grace period | minor, **Breaking** |
|
|
57
|
+
| Adding a new public name | minor |
|
|
58
|
+
| Adding an optional parameter with a backward-compatible default | minor |
|
|
59
|
+
| Deprecating something (it still works) | minor |
|
|
60
|
+
| New optional dependency or extra | minor |
|
|
61
|
+
| Bug fix that restores documented behaviour | patch |
|
|
62
|
+
| Performance work, internal refactor, doc or typo fix | patch |
|
|
63
|
+
| Widening an accepted type, or narrowing a return type | patch |
|
|
64
|
+
|
|
65
|
+
Two cases worth spelling out, because they are easy to pass off as fixes and
|
|
66
|
+
put in a patch:
|
|
67
|
+
|
|
68
|
+
- **Raising instead of silently degrading is a breaking change.** Code that used
|
|
69
|
+
to get a truncated result and now gets an exception is broken code, even
|
|
70
|
+
though the new behaviour is more correct.
|
|
71
|
+
- **Tightening validation is a breaking change.** Input that used to be accepted
|
|
72
|
+
and is now rejected breaks callers, however wrong that input was.
|
|
73
|
+
|
|
74
|
+
## Breaking changes
|
|
75
|
+
|
|
76
|
+
A breaking change is announced where the person upgrading will read it: under
|
|
77
|
+
`### Changed` or `### Removed` in the changelog, starting with **Breaking:**,
|
|
78
|
+
saying what changes and what to do (the setting that restores the former
|
|
79
|
+
behaviour, the name to use instead).
|
|
80
|
+
|
|
81
|
+
Deprecate first when the old and the new can live side by side: a renamed
|
|
82
|
+
function, a replaced parameter. A change of default or of validation cannot be
|
|
83
|
+
deprecated, and goes in directly.
|
|
84
|
+
|
|
85
|
+
## Deprecation policy
|
|
86
|
+
|
|
87
|
+
The cycle is:
|
|
88
|
+
|
|
89
|
+
1. **Deprecate in a minor release.** The old name keeps working, and is marked
|
|
90
|
+
with `@deprecated` from PEP 702:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from typing_extensions import deprecated
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@deprecated("Use search_all() instead; removed in 4.4.")
|
|
97
|
+
def search_everything() -> list[str]:
|
|
98
|
+
return search_all()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This is not just a runtime `DeprecationWarning`: type checkers (`ty`, mypy,
|
|
102
|
+
pyright) report the call site, so users see it in their editor and their CI
|
|
103
|
+
rather than only when warnings happen to be enabled.
|
|
104
|
+
|
|
105
|
+
2. **Say so in the changelog**, under `### Deprecated`, naming the replacement
|
|
106
|
+
and the version that will remove it.
|
|
107
|
+
|
|
108
|
+
3. **Remove in a later minor or major**, never sooner than one minor release
|
|
109
|
+
after the deprecation, and never before the version the message names. A name
|
|
110
|
+
deprecated in 4.2.0 can go in 4.3.0, but a name deprecated in the same release
|
|
111
|
+
that drops it never gets a grace period.
|
|
112
|
+
|
|
113
|
+
The message is part of the contract: it must name the replacement and the
|
|
114
|
+
removal version, so a user can act without reading the source.
|
|
115
|
+
|
|
116
|
+
> `typing_extensions` is a direct dependency for this reason — `typing.deprecated`
|
|
117
|
+
> only exists from Python 3.13, and this package supports 3.12.
|
|
118
|
+
|
|
119
|
+
## Release candidates
|
|
120
|
+
|
|
121
|
+
Tags shaped `vX.Y.Z-rc.N` build and publish to TestPyPI only; the PyPI job stays
|
|
122
|
+
manual. Use them to validate a release without committing to it.
|
|
123
|
+
|
|
124
|
+
## Consuming dot-inference
|
|
125
|
+
|
|
126
|
+
### From PyPI — the supported way
|
|
127
|
+
|
|
128
|
+
An application commits its lock file (`uv.lock`): the lock is what keeps it on
|
|
129
|
+
the version it was tested with, whatever gets published. The range in
|
|
130
|
+
`pyproject.toml` only decides what a lock refresh may bring in:
|
|
131
|
+
|
|
132
|
+
```toml
|
|
133
|
+
dependencies = ["dot-inference>=4.2,<4.3"] # patches only: nothing breaks
|
|
134
|
+
dependencies = ["dot-inference>=4.2,<5"] # minors too: read the Breaking entries first
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
A library that depends on `dot-inference` has no lock file to ship: only its range
|
|
138
|
+
counts. Give it the wide one (`>=4.2,<5`):
|
|
139
|
+
|
|
140
|
+
- With a narrow range (`<4.3`), the library would have to publish a new
|
|
141
|
+
version at every minor of `dot-inference`, only to allow it.
|
|
142
|
+
- In return, run the library's tests with the latest minor of `dot-inference`, so
|
|
143
|
+
that a break shows up there first.
|
|
144
|
+
- Raise the lower bound only when the library starts using something a newer
|
|
145
|
+
version added.
|
|
146
|
+
|
|
147
|
+
### From git — development only
|
|
148
|
+
|
|
149
|
+
Pinning a branch:
|
|
150
|
+
|
|
151
|
+
```toml
|
|
152
|
+
[tool.uv.sources]
|
|
153
|
+
dot-inference = { git = "...", rev = "main" } # don't do this in a published package
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
means accepting whatever lands on `main`, breaking changes included, with no
|
|
157
|
+
changelog entry yet to tell you so.
|
|
158
|
+
|
|
159
|
+
It is fine while developing two packages side by side — but keep it out of any
|
|
160
|
+
`pyproject.toml` you publish. Prefer a local, uncommitted override:
|
|
161
|
+
|
|
162
|
+
```shell
|
|
163
|
+
uv pip install -e ../dot-inference
|
|
164
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dot-inference"
|
|
3
|
-
version = "4.
|
|
3
|
+
version = "4.2.0"
|
|
4
4
|
description = "Unified async Python library for LLM inference and embeddings across multiple providers"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Kannon For Deep Tech", email = "louis.letarnec@deepika.ai" }]
|
|
@@ -11,7 +11,8 @@ from dot_inference._llm_registry import (
|
|
|
11
11
|
ResolvedModelConfig,
|
|
12
12
|
allowed_reasoning_efforts,
|
|
13
13
|
default_reasoning_effort,
|
|
14
|
-
get_context_window,
|
|
14
|
+
get_context_window, # ty: ignore[deprecated]
|
|
15
|
+
get_max_context_window,
|
|
15
16
|
get_model_config,
|
|
16
17
|
list_models,
|
|
17
18
|
register_model,
|
|
@@ -90,6 +91,7 @@ __all__ = [
|
|
|
90
91
|
"get_context_window",
|
|
91
92
|
"get_embedding_client",
|
|
92
93
|
"get_llm_client",
|
|
94
|
+
"get_max_context_window",
|
|
93
95
|
"get_model_config",
|
|
94
96
|
"has_images",
|
|
95
97
|
"image_part",
|
|
@@ -415,8 +415,8 @@ def _validate_reasoning_effort_for_model(
|
|
|
415
415
|
"""Raise ValueError if *reasoning_effort* isn't accepted by *model_id*.
|
|
416
416
|
|
|
417
417
|
A no-op for non-reasoning models (the value is ignored downstream), for
|
|
418
|
-
``None`` (means "use instance default"), and for models
|
|
419
|
-
|
|
418
|
+
``None`` (means "use instance default"), and for models the registry does
|
|
419
|
+
not know.
|
|
420
420
|
"""
|
|
421
421
|
if reasoning_effort is None or not supports_reasoning:
|
|
422
422
|
return
|
|
@@ -515,8 +515,8 @@ def get_llm_client(
|
|
|
515
515
|
resolve_llm_route(resolved_model, settings, provider=resolved_provider)
|
|
516
516
|
resolved_temperature = gen_settings.temperature if temperature is None else temperature
|
|
517
517
|
# Precedence: explicit call arg > the model's declared default > global
|
|
518
|
-
# default
|
|
519
|
-
#
|
|
518
|
+
# default (none unless the settings give one). With none of the three, no
|
|
519
|
+
# effort is sent: the provider, or the local server, applies its own.
|
|
520
520
|
if reasoning_effort is not None:
|
|
521
521
|
resolved_reasoning_effort = reasoning_effort
|
|
522
522
|
else:
|
|
@@ -15,6 +15,7 @@ from pathlib import Path
|
|
|
15
15
|
from typing import Any
|
|
16
16
|
|
|
17
17
|
import yaml
|
|
18
|
+
from typing_extensions import deprecated
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
@dataclass(frozen=True)
|
|
@@ -33,6 +34,11 @@ class ProviderModelConfig:
|
|
|
33
34
|
# Per-provider override for image input (None = inherit from model), e.g.
|
|
34
35
|
# a local server running a text-only build of a multimodal model.
|
|
35
36
|
supports_vision: bool | None = None
|
|
37
|
+
# For a server that does not read ``reasoning_effort`` (a self-hosted model
|
|
38
|
+
# whose chat template has its own variables): the ``chat_template_kwargs``
|
|
39
|
+
# sent for each effort, in place of ``reasoning_effort``. Its efforts are
|
|
40
|
+
# those the model accepts. Empty: ``reasoning_effort`` is sent.
|
|
41
|
+
reasoning_chat_template_kwargs: dict[str, dict[str, Any]] = field(default_factory=dict)
|
|
36
42
|
# OpenRouter-specific features (ignored by other providers)
|
|
37
43
|
response_healing: bool = False
|
|
38
44
|
fallback_models: list[str] = field(default_factory=list)
|
|
@@ -62,17 +68,37 @@ class ModelConfig:
|
|
|
62
68
|
output_token_cost: float | None = None
|
|
63
69
|
# Maximum tokens (input + output) the model accepts in one request.
|
|
64
70
|
# Model-level (not per-provider) — public spec value. ``None`` when
|
|
65
|
-
# the figure is not declared.
|
|
71
|
+
# the figure is not declared. A self-hosted server may be started with
|
|
72
|
+
# less: ``LocalEndpointCheck.context_window`` is what it serves.
|
|
66
73
|
context_window: int | None = None
|
|
67
74
|
default_provider: str | None = None
|
|
68
|
-
# The reasoning_effort values this model accepts
|
|
69
|
-
#
|
|
75
|
+
# The reasoning_effort values this model accepts: required when the model
|
|
76
|
+
# reasons, an effort name not being shared from one model to the next.
|
|
70
77
|
reasoning_effort_options: list[str] = field(default_factory=list)
|
|
71
|
-
# The effort used when the caller specifies none
|
|
72
|
-
#
|
|
78
|
+
# The effort used when the caller specifies none. None: the global
|
|
79
|
+
# GenerationSettings one, and none is sent when that is None too.
|
|
73
80
|
default_reasoning_effort: str | None = None
|
|
74
81
|
providers: dict[str, ProviderModelConfig] = field(default_factory=dict)
|
|
75
82
|
|
|
83
|
+
def __post_init__(self) -> None:
|
|
84
|
+
efforts = self.reasoning_effort_options
|
|
85
|
+
reasons = self.supports_reasoning or any(
|
|
86
|
+
pmc.supports_reasoning for pmc in self.providers.values()
|
|
87
|
+
)
|
|
88
|
+
if reasons and not efforts:
|
|
89
|
+
raise ValueError(
|
|
90
|
+
f"Model '{self.model_id}' reasons (supports_reasoning) and declares no "
|
|
91
|
+
"reasoning_effort_options: list the efforts it accepts."
|
|
92
|
+
)
|
|
93
|
+
for provider, pmc in self.providers.items():
|
|
94
|
+
by_effort = pmc.reasoning_chat_template_kwargs
|
|
95
|
+
if by_effort and set(by_effort) != set(efforts):
|
|
96
|
+
raise ValueError(
|
|
97
|
+
f"Model '{self.model_id}', provider '{provider}': "
|
|
98
|
+
f"reasoning_chat_template_kwargs covers {sorted(by_effort)}, "
|
|
99
|
+
f"the model's reasoning efforts are {sorted(efforts)}."
|
|
100
|
+
)
|
|
101
|
+
|
|
76
102
|
def for_provider(self, provider: str) -> ResolvedModelConfig:
|
|
77
103
|
"""Resolve a flattened config for a specific provider.
|
|
78
104
|
|
|
@@ -103,6 +129,7 @@ class ModelConfig:
|
|
|
103
129
|
if pmc.output_token_cost is not None
|
|
104
130
|
else self.output_token_cost,
|
|
105
131
|
context_window=self.context_window,
|
|
132
|
+
reasoning_chat_template_kwargs=pmc.reasoning_chat_template_kwargs,
|
|
106
133
|
response_healing=pmc.response_healing,
|
|
107
134
|
fallback_models=pmc.fallback_models,
|
|
108
135
|
provider_routing=pmc.provider_routing,
|
|
@@ -125,6 +152,7 @@ class ResolvedModelConfig:
|
|
|
125
152
|
input_token_cost: float | None = None
|
|
126
153
|
output_token_cost: float | None = None
|
|
127
154
|
context_window: int | None = None
|
|
155
|
+
reasoning_chat_template_kwargs: dict[str, dict[str, Any]] = field(default_factory=dict)
|
|
128
156
|
# OpenRouter-specific (no-ops for other providers)
|
|
129
157
|
response_healing: bool = False
|
|
130
158
|
fallback_models: list[str] = field(default_factory=list)
|
|
@@ -155,6 +183,9 @@ def _parse_models_yaml(raw: dict[str, Any]) -> dict[str, ModelConfig]:
|
|
|
155
183
|
supports_reasoning=prov_cfg.get("supports_reasoning"),
|
|
156
184
|
supports_temperature=prov_cfg.get("supports_temperature"),
|
|
157
185
|
supports_vision=prov_cfg.get("supports_vision"),
|
|
186
|
+
reasoning_chat_template_kwargs=dict(
|
|
187
|
+
prov_cfg.get("reasoning_chat_template_kwargs") or {}
|
|
188
|
+
),
|
|
158
189
|
response_healing=features.get("response_healing", False),
|
|
159
190
|
fallback_models=features.get("fallback_models", []),
|
|
160
191
|
provider_routing=features.get("provider_routing"),
|
|
@@ -279,12 +310,23 @@ def get_default_provider(model_id: str) -> str | None:
|
|
|
279
310
|
return model.default_provider if model is not None else None
|
|
280
311
|
|
|
281
312
|
|
|
282
|
-
def
|
|
283
|
-
"""Return the
|
|
313
|
+
def get_max_context_window(model_id: str) -> int | None:
|
|
314
|
+
"""Return the largest context window *model_id* accepts, or None if unknown.
|
|
315
|
+
|
|
316
|
+
It is the model's limit, as the registry declares it. A self-hosted server
|
|
317
|
+
may be started with less: ``check_local_endpoint(model_id)`` gives the
|
|
318
|
+
window it serves (``LocalEndpointCheck.context_window``).
|
|
319
|
+
"""
|
|
284
320
|
model = _load_registry().get(model_id)
|
|
285
321
|
return model.context_window if model is not None else None
|
|
286
322
|
|
|
287
323
|
|
|
324
|
+
@deprecated("Use get_max_context_window() instead; removed in 5.0.")
|
|
325
|
+
def get_context_window(model_id: str) -> int | None:
|
|
326
|
+
"""The former name of :func:`get_max_context_window`."""
|
|
327
|
+
return get_max_context_window(model_id)
|
|
328
|
+
|
|
329
|
+
|
|
288
330
|
def list_models(provider: str | None = None) -> list[str]:
|
|
289
331
|
"""Return registered model IDs, optionally filtered by provider availability."""
|
|
290
332
|
registry = _load_registry()
|
|
@@ -293,28 +335,18 @@ def list_models(provider: str | None = None) -> list[str]:
|
|
|
293
335
|
return [mid for mid, mc in registry.items() if provider in mc.providers]
|
|
294
336
|
|
|
295
337
|
|
|
296
|
-
# Fallback effort ladder for reasoning models that don't declare an explicit
|
|
297
|
-
# option set (the OpenAI/Anthropic convention). "none" is intentionally
|
|
298
|
-
# excluded — it's opt-in via reasoning_effort_options (Mistral models).
|
|
299
|
-
# TODO: this will be made better later.
|
|
300
|
-
_DEFAULT_REASONING_LADDER = ["low", "medium", "high"]
|
|
301
|
-
|
|
302
|
-
|
|
303
338
|
def allowed_reasoning_efforts(model_id: str) -> list[str]:
|
|
304
339
|
"""Return the reasoning_effort values valid for *model_id*.
|
|
305
340
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
high]
|
|
310
|
-
given model accepts — Mistral Medium 3.5 returns ``[none, high]``.
|
|
341
|
+
They are the model's ``reasoning_effort_options``; an empty list when the
|
|
342
|
+
model is unknown or doesn't support reasoning. Lets a caller (e.g. a client
|
|
343
|
+
UI) offer only the choices a given model accepts — Mistral Medium 3.5
|
|
344
|
+
returns ``[none, high]``.
|
|
311
345
|
"""
|
|
312
346
|
model = _load_registry().get(model_id)
|
|
313
347
|
if model is None or not model.supports_reasoning:
|
|
314
348
|
return []
|
|
315
|
-
|
|
316
|
-
return list(model.reasoning_effort_options)
|
|
317
|
-
return list(_DEFAULT_REASONING_LADDER)
|
|
349
|
+
return list(model.reasoning_effort_options)
|
|
318
350
|
|
|
319
351
|
|
|
320
352
|
def default_reasoning_effort(model_id: str) -> str | None:
|
|
@@ -322,7 +354,7 @@ def default_reasoning_effort(model_id: str) -> str | None:
|
|
|
322
354
|
|
|
323
355
|
``None`` when the model is unknown, doesn't support reasoning, or simply
|
|
324
356
|
doesn't pin a default (in which case the caller's global default
|
|
325
|
-
applies).
|
|
357
|
+
applies, and no effort is sent when there is none).
|
|
326
358
|
"""
|
|
327
359
|
model = _load_registry().get(model_id)
|
|
328
360
|
if model is None or not model.supports_reasoning:
|
|
@@ -12,6 +12,7 @@ detect that situation up front by comparing the registry's expected
|
|
|
12
12
|
from __future__ import annotations
|
|
13
13
|
|
|
14
14
|
from dataclasses import dataclass
|
|
15
|
+
from typing import Any
|
|
15
16
|
|
|
16
17
|
import httpx
|
|
17
18
|
|
|
@@ -28,6 +29,10 @@ class LocalEndpointCheck:
|
|
|
28
29
|
expected_model: str
|
|
29
30
|
# Model ids the endpoint reports via GET /models.
|
|
30
31
|
served_models: list[str]
|
|
32
|
+
# The context window the endpoint serves the expected model with, in tokens
|
|
33
|
+
# (``max_model_len``, as vLLM and SGLang report it). None when the endpoint
|
|
34
|
+
# does not report one, or does not serve the model.
|
|
35
|
+
context_window: int | None = None
|
|
31
36
|
|
|
32
37
|
@property
|
|
33
38
|
def matches(self) -> bool:
|
|
@@ -49,11 +54,18 @@ async def list_served_models(
|
|
|
49
54
|
|
|
50
55
|
*transport* is a test seam (``httpx.MockTransport``).
|
|
51
56
|
"""
|
|
57
|
+
return [m["id"] for m in await _served(base_url, timeout, transport)]
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def _served(
|
|
61
|
+
base_url: str, timeout: float, transport: httpx.AsyncBaseTransport | None
|
|
62
|
+
) -> list[dict[str, Any]]:
|
|
63
|
+
"""The entries of the server's ``GET /models`` that name a model."""
|
|
52
64
|
async with httpx.AsyncClient(timeout=timeout, transport=transport) as client:
|
|
53
65
|
resp = await client.get(f"{base_url.rstrip('/')}/models")
|
|
54
66
|
resp.raise_for_status()
|
|
55
67
|
data = resp.json().get("data", [])
|
|
56
|
-
return [m
|
|
68
|
+
return [m for m in data if isinstance(m, dict) and "id" in m]
|
|
57
69
|
|
|
58
70
|
|
|
59
71
|
async def check_local_endpoint(
|
|
@@ -109,8 +121,11 @@ async def _probe(
|
|
|
109
121
|
) -> LocalEndpointCheck | None:
|
|
110
122
|
if route.provider is not Provider.LOCAL or not base_url:
|
|
111
123
|
return None
|
|
124
|
+
served = await _served(base_url, timeout, transport)
|
|
125
|
+
window = next((m.get("max_model_len") for m in served if m["id"] == route.api_model_name), None)
|
|
112
126
|
return LocalEndpointCheck(
|
|
113
127
|
base_url=base_url,
|
|
114
128
|
expected_model=route.api_model_name,
|
|
115
|
-
served_models=
|
|
129
|
+
served_models=[m["id"] for m in served],
|
|
130
|
+
context_window=window if isinstance(window, int) else None,
|
|
116
131
|
)
|