dbx-tools-litellm 0.6.92__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.
- dbx_tools_litellm-0.6.92/PKG-INFO +235 -0
- dbx_tools_litellm-0.6.92/README.md +223 -0
- dbx_tools_litellm-0.6.92/pyproject.toml +27 -0
- dbx_tools_litellm-0.6.92/pyproject.toml.orig +29 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/__init__.py +24 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/__main__.py +5 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/access_log.py +228 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/backend.py +158 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/cli.py +62 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/config.yaml +41 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/config_provider.py +8 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/credentials.py +130 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/models.py +70 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/models_api.py +289 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/provider.py +389 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/reasoning.py +476 -0
- dbx_tools_litellm-0.6.92/src/dbx_tools/litellm/routing.py +75 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: dbx-tools-litellm
|
|
3
|
+
Version: 0.6.92
|
|
4
|
+
Summary: LiteLLM custom provider for Databricks Model Serving with live fuzzy model resolution
|
|
5
|
+
Requires-Dist: databricks-sdk>=0.63.0
|
|
6
|
+
Requires-Dist: dbx-tools-model==0.6.92
|
|
7
|
+
Requires-Dist: diskcache>=5.6
|
|
8
|
+
Requires-Dist: litellm[proxy]>=1.83.14
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Project-URL: Source, https://github.com/reggie-db/dbx-tools/tree/main/packages/py/litellm
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# `dbx-tools-litellm`
|
|
14
|
+
|
|
15
|
+
Thin LiteLLM integration for Databricks Model Serving. It adds live endpoint
|
|
16
|
+
discovery and loose model-name resolution, then delegates the unchanged request
|
|
17
|
+
to LiteLLM's built-in Databricks provider.
|
|
18
|
+
|
|
19
|
+
Install from PyPI:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv add dbx-tools-litellm
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
To install the current `main` branch directly from the repository instead:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
uv add "dbx-tools-litellm @ git+https://github.com/reggie-db/dbx-tools.git@main#subdirectory=packages/py/litellm"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Key features
|
|
32
|
+
|
|
33
|
+
- resolves a Databricks profile from `--profile`, then
|
|
34
|
+
`DATABRICKS_CONFIG_PROFILE`, then the Databricks CLI's configured default;
|
|
35
|
+
- discovers serving endpoints from the selected workspace and caches them per
|
|
36
|
+
process;
|
|
37
|
+
- advertises discovered endpoints and family aliases only under `dbx/*` by
|
|
38
|
+
default, keeping them distinct from LiteLLM's native `databricks/*` provider;
|
|
39
|
+
- resolves exact or fuzzy model names with `dbx-tools-model`, refreshing the
|
|
40
|
+
live catalogue once after a miss;
|
|
41
|
+
- restricts tool-bearing requests to endpoints classified as tool-capable;
|
|
42
|
+
- routes Responses-only models through LiteLLM's
|
|
43
|
+
`databricks/responses/...` bridge;
|
|
44
|
+
- resolves Responses-only proxy calls before provider selection so LiteLLM's
|
|
45
|
+
native Databricks Responses implementation receives the original body;
|
|
46
|
+
- optionally classifies an `auto` reasoning effort as `low`, `medium`, or
|
|
47
|
+
`high` for reasoning-capable OpenAI and Claude endpoints;
|
|
48
|
+
- supports LiteLLM chat, embedding, synchronous/asynchronous, and streaming
|
|
49
|
+
entrypoints without custom request-content rewriting.
|
|
50
|
+
|
|
51
|
+
## Run the proxy
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
uv run dbx-litellm --port 4000
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The launcher listens on `127.0.0.1` by default. Pass an explicit LiteLLM
|
|
58
|
+
`--host` value or set `HOST` to expose it on another interface.
|
|
59
|
+
Pass `--profile my-workspace` to override both the environment and CLI default.
|
|
60
|
+
|
|
61
|
+
The equivalent module invocation is:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
uv run python -m dbx_tools.litellm --port 4000
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Then point an OpenAI-compatible client at `http://127.0.0.1:4000/v1`:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
curl http://127.0.0.1:4000/v1/chat/completions \
|
|
71
|
+
-H 'content-type: application/json' \
|
|
72
|
+
-d '{"model":"dbx/databricks-claude","messages":[{"role":"user","content":"hi"}]}'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The resolved profile is written to `DATABRICKS_CONFIG_PROFILE`, so endpoint
|
|
76
|
+
discovery and LiteLLM's delegated Databricks request use the same workspace
|
|
77
|
+
credentials.
|
|
78
|
+
|
|
79
|
+
## Relationship to LiteLLM
|
|
80
|
+
|
|
81
|
+
LiteLLM remains the proxy and provider implementation. It owns the
|
|
82
|
+
OpenAI-compatible routes, Databricks authentication and transport, parameter
|
|
83
|
+
mapping, streaming semantics, retries, embeddings, and Chat↔Responses
|
|
84
|
+
conversion.
|
|
85
|
+
|
|
86
|
+
This package supplies only the workspace-specific layer LiteLLM does not have:
|
|
87
|
+
deterministic profile selection, live endpoint discovery, fuzzy names, and
|
|
88
|
+
capability-aware routing. Request messages, content blocks, tools, and provider
|
|
89
|
+
options are not rewritten except when the caller explicitly requests automatic
|
|
90
|
+
reasoning selection.
|
|
91
|
+
|
|
92
|
+
LiteLLM 1.83 loads custom handlers from a Python file beside the config. For an
|
|
93
|
+
existing LiteLLM config, add `config_provider.py` next to the YAML:
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from dbx_tools.litellm.provider import dbx_provider
|
|
97
|
+
from dbx_tools.litellm.reasoning import dbx_auto_reasoning
|
|
98
|
+
from dbx_tools.litellm.routing import dbx_responses_router
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Then register that adjacent shim under `dbx`:
|
|
102
|
+
|
|
103
|
+
```yaml
|
|
104
|
+
model_list:
|
|
105
|
+
- model_name: "dbx/*"
|
|
106
|
+
litellm_params:
|
|
107
|
+
model: "dbx/*"
|
|
108
|
+
allowed_openai_params:
|
|
109
|
+
- reasoning_effort
|
|
110
|
+
- thinking
|
|
111
|
+
|
|
112
|
+
litellm_settings:
|
|
113
|
+
callbacks:
|
|
114
|
+
- config_provider.dbx_auto_reasoning
|
|
115
|
+
- config_provider.dbx_responses_router
|
|
116
|
+
custom_provider_map:
|
|
117
|
+
- provider: dbx
|
|
118
|
+
custom_handler: config_provider.dbx_provider
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The packaged config advertises only `dbx/*`. A consumer config can opt into
|
|
122
|
+
LiteLLM's native Databricks provider independently:
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
model_list:
|
|
126
|
+
- model_name: "databricks/*"
|
|
127
|
+
litellm_params:
|
|
128
|
+
model: "databricks/*"
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Set `DATABRICKS_CONFIG_PROFILE` before starting LiteLLM to override the
|
|
132
|
+
Databricks CLI default when `--profile` is not available.
|
|
133
|
+
|
|
134
|
+
## Automatic reasoning effort
|
|
135
|
+
|
|
136
|
+
Automatic effort is opt-in. On Chat Completions, send
|
|
137
|
+
`"reasoning_effort": "auto"`:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"model": "claude sonnet",
|
|
142
|
+
"messages": [{ "role": "user", "content": "Debug this distributed deadlock" }],
|
|
143
|
+
"reasoning_effort": "auto"
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
On Responses, use the native reasoning shape:
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"model": "gpt 5 codex",
|
|
152
|
+
"input": "Debug this distributed deadlock",
|
|
153
|
+
"reasoning": { "effort": "auto" }
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The callback resolves `databricks-meta-llama-3-1-8b-instruct` against the live
|
|
158
|
+
catalogue as its fallback classifier preference, asks the discovered endpoint
|
|
159
|
+
for a score from `0.01` through `1.00`, then maps that score through the target
|
|
160
|
+
Databricks endpoint's inferred reasoning levels. Scores below `0.34` use `low`,
|
|
161
|
+
scores below `0.67` use `medium`, and higher scores use `high`. An exact `1.00` uses the
|
|
162
|
+
GPT-5.6 ultra tier, whose LiteLLM wire value is `xhigh`; models without that
|
|
163
|
+
level remain at `high`. Integer classifier output is treated as a percentage
|
|
164
|
+
(`73` becomes `0.73`), except `1`, which remains the maximum score.
|
|
165
|
+
|
|
166
|
+
Explicit `low`, `medium`, `high`, `xhigh`, or `thinking` values are never
|
|
167
|
+
overridden. Unsupported targets have `auto` removed and use their normal
|
|
168
|
+
provider default.
|
|
169
|
+
|
|
170
|
+
The classifier sees at most eight recent non-system turns and 6,000 characters.
|
|
171
|
+
Full Chat transcripts are sampled directly. Short follow-ups can recover prior
|
|
172
|
+
turns from `metadata.thread_id`, `metadata.conversation_id`, or
|
|
173
|
+
`metadata.session_id`; Responses chains are linked through
|
|
174
|
+
`previous_response_id`. Context and classification scores use `diskcache` with
|
|
175
|
+
a TTL, so retries and follow-ups avoid repeated classifier calls without
|
|
176
|
+
retaining an unbounded transcript.
|
|
177
|
+
|
|
178
|
+
Configuration:
|
|
179
|
+
|
|
180
|
+
- `DBX_TOOLS_LITELLM_REASONING_MODEL` overrides the classifier endpoint;
|
|
181
|
+
- `DBX_TOOLS_LITELLM_REASONING_CACHE_DIR` changes the disk-cache directory;
|
|
182
|
+
- `DBX_TOOLS_LITELLM_REASONING_CACHE_TTL_SECONDS` sets the context and result
|
|
183
|
+
TTL (default: 86,400 seconds);
|
|
184
|
+
- `DBX_TOOLS_LITELLM_REASONING_TIMEOUT_SECONDS` sets the classifier timeout
|
|
185
|
+
(default: 5 seconds).
|
|
186
|
+
|
|
187
|
+
For Claude targets, LiteLLM's Databricks transformer maps the selected
|
|
188
|
+
`reasoning_effort` to the backend's native extended-thinking token budget.
|
|
189
|
+
|
|
190
|
+
The one-line `dbx-access` record includes `thinking_requested=<level>` for every
|
|
191
|
+
request. Automatic requests also include `thinking_selected=<level>` after the
|
|
192
|
+
classifier maps the score through the resolved model's capabilities. The
|
|
193
|
+
existing `reasoning=<tokens>` field remains the number of reasoning tokens
|
|
194
|
+
reported by the provider, not the selected effort level.
|
|
195
|
+
|
|
196
|
+
## Runtime behavior
|
|
197
|
+
|
|
198
|
+
Endpoint discovery is lazy. The first request lists serving endpoints, later
|
|
199
|
+
requests reuse that catalogue, and an unresolved name triggers one refresh
|
|
200
|
+
before the unresolved endpoint id is delegated to Databricks. `/v1/models`
|
|
201
|
+
refreshes the profile's live serving endpoints and uses that discovery as the
|
|
202
|
+
exact model list, including endpoints such as `databricks-gpt-5-6-sol`.
|
|
203
|
+
LiteLLM's bundled registry supplies metadata for matching live models and is
|
|
204
|
+
used as a fallback only when live discovery fails. The response then appends one
|
|
205
|
+
basic alias for each recognized deployed family. Exact models and aliases are
|
|
206
|
+
advertised as `dbx/databricks-gpt-5-6-sol`, `dbx/databricks-gpt`, and similar
|
|
207
|
+
ids. The aliases flow through the same fuzzy resolver and do not replace exact
|
|
208
|
+
models. A custom config that declares `databricks/*` opts into native model ids
|
|
209
|
+
alongside the dbx ids.
|
|
210
|
+
|
|
211
|
+
The proxy owns one process-wide SDK client and bearer cache. A fresh cache read
|
|
212
|
+
returns without locking; a stale read acquires an `RLock`, checks again, and
|
|
213
|
+
performs one synchronous SDK authentication load. SDK background refresh is
|
|
214
|
+
disabled so parallel requests cannot start a second refresh path.
|
|
215
|
+
|
|
216
|
+
LiteLLM's `CustomLLM` interface has no native Responses hook. For a
|
|
217
|
+
Responses-only endpoint, the packaged proxy's pre-call hook changes only the
|
|
218
|
+
model identifier to `databricks/<resolved-endpoint>`; LiteLLM's native
|
|
219
|
+
Databricks Responses implementation receives the original body. Other model
|
|
220
|
+
families use LiteLLM's own Responses-to-Chat fallback.
|
|
221
|
+
|
|
222
|
+
## Modules
|
|
223
|
+
|
|
224
|
+
- `backend` - profile-resolved workspace client, endpoint cache, and model
|
|
225
|
+
resolution;
|
|
226
|
+
- `models` — Responses-only endpoint routing policy;
|
|
227
|
+
- `provider` — LiteLLM `CustomLLM` adapter and exported `dbx_provider`
|
|
228
|
+
singleton;
|
|
229
|
+
- `reasoning` — opt-in effort classification and TTL-backed follow-up context;
|
|
230
|
+
- `routing` — model-only proxy hook for native Responses-only calls;
|
|
231
|
+
- `cli` - profile-resolving launcher for the packaged LiteLLM proxy config.
|
|
232
|
+
|
|
233
|
+
For standalone Python endpoint resolution and invocation helpers, use
|
|
234
|
+
[`dbx-tools-model`](../model). For the TypeScript local proxy, use
|
|
235
|
+
[`@dbx-tools/cli-model-proxy`](../../js/cli/model-proxy).
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# `dbx-tools-litellm`
|
|
2
|
+
|
|
3
|
+
Thin LiteLLM integration for Databricks Model Serving. It adds live endpoint
|
|
4
|
+
discovery and loose model-name resolution, then delegates the unchanged request
|
|
5
|
+
to LiteLLM's built-in Databricks provider.
|
|
6
|
+
|
|
7
|
+
Install from PyPI:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
uv add dbx-tools-litellm
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
To install the current `main` branch directly from the repository instead:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
uv add "dbx-tools-litellm @ git+https://github.com/reggie-db/dbx-tools.git@main#subdirectory=packages/py/litellm"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Key features
|
|
20
|
+
|
|
21
|
+
- resolves a Databricks profile from `--profile`, then
|
|
22
|
+
`DATABRICKS_CONFIG_PROFILE`, then the Databricks CLI's configured default;
|
|
23
|
+
- discovers serving endpoints from the selected workspace and caches them per
|
|
24
|
+
process;
|
|
25
|
+
- advertises discovered endpoints and family aliases only under `dbx/*` by
|
|
26
|
+
default, keeping them distinct from LiteLLM's native `databricks/*` provider;
|
|
27
|
+
- resolves exact or fuzzy model names with `dbx-tools-model`, refreshing the
|
|
28
|
+
live catalogue once after a miss;
|
|
29
|
+
- restricts tool-bearing requests to endpoints classified as tool-capable;
|
|
30
|
+
- routes Responses-only models through LiteLLM's
|
|
31
|
+
`databricks/responses/...` bridge;
|
|
32
|
+
- resolves Responses-only proxy calls before provider selection so LiteLLM's
|
|
33
|
+
native Databricks Responses implementation receives the original body;
|
|
34
|
+
- optionally classifies an `auto` reasoning effort as `low`, `medium`, or
|
|
35
|
+
`high` for reasoning-capable OpenAI and Claude endpoints;
|
|
36
|
+
- supports LiteLLM chat, embedding, synchronous/asynchronous, and streaming
|
|
37
|
+
entrypoints without custom request-content rewriting.
|
|
38
|
+
|
|
39
|
+
## Run the proxy
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
uv run dbx-litellm --port 4000
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The launcher listens on `127.0.0.1` by default. Pass an explicit LiteLLM
|
|
46
|
+
`--host` value or set `HOST` to expose it on another interface.
|
|
47
|
+
Pass `--profile my-workspace` to override both the environment and CLI default.
|
|
48
|
+
|
|
49
|
+
The equivalent module invocation is:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv run python -m dbx_tools.litellm --port 4000
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then point an OpenAI-compatible client at `http://127.0.0.1:4000/v1`:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
curl http://127.0.0.1:4000/v1/chat/completions \
|
|
59
|
+
-H 'content-type: application/json' \
|
|
60
|
+
-d '{"model":"dbx/databricks-claude","messages":[{"role":"user","content":"hi"}]}'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The resolved profile is written to `DATABRICKS_CONFIG_PROFILE`, so endpoint
|
|
64
|
+
discovery and LiteLLM's delegated Databricks request use the same workspace
|
|
65
|
+
credentials.
|
|
66
|
+
|
|
67
|
+
## Relationship to LiteLLM
|
|
68
|
+
|
|
69
|
+
LiteLLM remains the proxy and provider implementation. It owns the
|
|
70
|
+
OpenAI-compatible routes, Databricks authentication and transport, parameter
|
|
71
|
+
mapping, streaming semantics, retries, embeddings, and Chat↔Responses
|
|
72
|
+
conversion.
|
|
73
|
+
|
|
74
|
+
This package supplies only the workspace-specific layer LiteLLM does not have:
|
|
75
|
+
deterministic profile selection, live endpoint discovery, fuzzy names, and
|
|
76
|
+
capability-aware routing. Request messages, content blocks, tools, and provider
|
|
77
|
+
options are not rewritten except when the caller explicitly requests automatic
|
|
78
|
+
reasoning selection.
|
|
79
|
+
|
|
80
|
+
LiteLLM 1.83 loads custom handlers from a Python file beside the config. For an
|
|
81
|
+
existing LiteLLM config, add `config_provider.py` next to the YAML:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
from dbx_tools.litellm.provider import dbx_provider
|
|
85
|
+
from dbx_tools.litellm.reasoning import dbx_auto_reasoning
|
|
86
|
+
from dbx_tools.litellm.routing import dbx_responses_router
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Then register that adjacent shim under `dbx`:
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
model_list:
|
|
93
|
+
- model_name: "dbx/*"
|
|
94
|
+
litellm_params:
|
|
95
|
+
model: "dbx/*"
|
|
96
|
+
allowed_openai_params:
|
|
97
|
+
- reasoning_effort
|
|
98
|
+
- thinking
|
|
99
|
+
|
|
100
|
+
litellm_settings:
|
|
101
|
+
callbacks:
|
|
102
|
+
- config_provider.dbx_auto_reasoning
|
|
103
|
+
- config_provider.dbx_responses_router
|
|
104
|
+
custom_provider_map:
|
|
105
|
+
- provider: dbx
|
|
106
|
+
custom_handler: config_provider.dbx_provider
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The packaged config advertises only `dbx/*`. A consumer config can opt into
|
|
110
|
+
LiteLLM's native Databricks provider independently:
|
|
111
|
+
|
|
112
|
+
```yaml
|
|
113
|
+
model_list:
|
|
114
|
+
- model_name: "databricks/*"
|
|
115
|
+
litellm_params:
|
|
116
|
+
model: "databricks/*"
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Set `DATABRICKS_CONFIG_PROFILE` before starting LiteLLM to override the
|
|
120
|
+
Databricks CLI default when `--profile` is not available.
|
|
121
|
+
|
|
122
|
+
## Automatic reasoning effort
|
|
123
|
+
|
|
124
|
+
Automatic effort is opt-in. On Chat Completions, send
|
|
125
|
+
`"reasoning_effort": "auto"`:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"model": "claude sonnet",
|
|
130
|
+
"messages": [{ "role": "user", "content": "Debug this distributed deadlock" }],
|
|
131
|
+
"reasoning_effort": "auto"
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
On Responses, use the native reasoning shape:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"model": "gpt 5 codex",
|
|
140
|
+
"input": "Debug this distributed deadlock",
|
|
141
|
+
"reasoning": { "effort": "auto" }
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
The callback resolves `databricks-meta-llama-3-1-8b-instruct` against the live
|
|
146
|
+
catalogue as its fallback classifier preference, asks the discovered endpoint
|
|
147
|
+
for a score from `0.01` through `1.00`, then maps that score through the target
|
|
148
|
+
Databricks endpoint's inferred reasoning levels. Scores below `0.34` use `low`,
|
|
149
|
+
scores below `0.67` use `medium`, and higher scores use `high`. An exact `1.00` uses the
|
|
150
|
+
GPT-5.6 ultra tier, whose LiteLLM wire value is `xhigh`; models without that
|
|
151
|
+
level remain at `high`. Integer classifier output is treated as a percentage
|
|
152
|
+
(`73` becomes `0.73`), except `1`, which remains the maximum score.
|
|
153
|
+
|
|
154
|
+
Explicit `low`, `medium`, `high`, `xhigh`, or `thinking` values are never
|
|
155
|
+
overridden. Unsupported targets have `auto` removed and use their normal
|
|
156
|
+
provider default.
|
|
157
|
+
|
|
158
|
+
The classifier sees at most eight recent non-system turns and 6,000 characters.
|
|
159
|
+
Full Chat transcripts are sampled directly. Short follow-ups can recover prior
|
|
160
|
+
turns from `metadata.thread_id`, `metadata.conversation_id`, or
|
|
161
|
+
`metadata.session_id`; Responses chains are linked through
|
|
162
|
+
`previous_response_id`. Context and classification scores use `diskcache` with
|
|
163
|
+
a TTL, so retries and follow-ups avoid repeated classifier calls without
|
|
164
|
+
retaining an unbounded transcript.
|
|
165
|
+
|
|
166
|
+
Configuration:
|
|
167
|
+
|
|
168
|
+
- `DBX_TOOLS_LITELLM_REASONING_MODEL` overrides the classifier endpoint;
|
|
169
|
+
- `DBX_TOOLS_LITELLM_REASONING_CACHE_DIR` changes the disk-cache directory;
|
|
170
|
+
- `DBX_TOOLS_LITELLM_REASONING_CACHE_TTL_SECONDS` sets the context and result
|
|
171
|
+
TTL (default: 86,400 seconds);
|
|
172
|
+
- `DBX_TOOLS_LITELLM_REASONING_TIMEOUT_SECONDS` sets the classifier timeout
|
|
173
|
+
(default: 5 seconds).
|
|
174
|
+
|
|
175
|
+
For Claude targets, LiteLLM's Databricks transformer maps the selected
|
|
176
|
+
`reasoning_effort` to the backend's native extended-thinking token budget.
|
|
177
|
+
|
|
178
|
+
The one-line `dbx-access` record includes `thinking_requested=<level>` for every
|
|
179
|
+
request. Automatic requests also include `thinking_selected=<level>` after the
|
|
180
|
+
classifier maps the score through the resolved model's capabilities. The
|
|
181
|
+
existing `reasoning=<tokens>` field remains the number of reasoning tokens
|
|
182
|
+
reported by the provider, not the selected effort level.
|
|
183
|
+
|
|
184
|
+
## Runtime behavior
|
|
185
|
+
|
|
186
|
+
Endpoint discovery is lazy. The first request lists serving endpoints, later
|
|
187
|
+
requests reuse that catalogue, and an unresolved name triggers one refresh
|
|
188
|
+
before the unresolved endpoint id is delegated to Databricks. `/v1/models`
|
|
189
|
+
refreshes the profile's live serving endpoints and uses that discovery as the
|
|
190
|
+
exact model list, including endpoints such as `databricks-gpt-5-6-sol`.
|
|
191
|
+
LiteLLM's bundled registry supplies metadata for matching live models and is
|
|
192
|
+
used as a fallback only when live discovery fails. The response then appends one
|
|
193
|
+
basic alias for each recognized deployed family. Exact models and aliases are
|
|
194
|
+
advertised as `dbx/databricks-gpt-5-6-sol`, `dbx/databricks-gpt`, and similar
|
|
195
|
+
ids. The aliases flow through the same fuzzy resolver and do not replace exact
|
|
196
|
+
models. A custom config that declares `databricks/*` opts into native model ids
|
|
197
|
+
alongside the dbx ids.
|
|
198
|
+
|
|
199
|
+
The proxy owns one process-wide SDK client and bearer cache. A fresh cache read
|
|
200
|
+
returns without locking; a stale read acquires an `RLock`, checks again, and
|
|
201
|
+
performs one synchronous SDK authentication load. SDK background refresh is
|
|
202
|
+
disabled so parallel requests cannot start a second refresh path.
|
|
203
|
+
|
|
204
|
+
LiteLLM's `CustomLLM` interface has no native Responses hook. For a
|
|
205
|
+
Responses-only endpoint, the packaged proxy's pre-call hook changes only the
|
|
206
|
+
model identifier to `databricks/<resolved-endpoint>`; LiteLLM's native
|
|
207
|
+
Databricks Responses implementation receives the original body. Other model
|
|
208
|
+
families use LiteLLM's own Responses-to-Chat fallback.
|
|
209
|
+
|
|
210
|
+
## Modules
|
|
211
|
+
|
|
212
|
+
- `backend` - profile-resolved workspace client, endpoint cache, and model
|
|
213
|
+
resolution;
|
|
214
|
+
- `models` — Responses-only endpoint routing policy;
|
|
215
|
+
- `provider` — LiteLLM `CustomLLM` adapter and exported `dbx_provider`
|
|
216
|
+
singleton;
|
|
217
|
+
- `reasoning` — opt-in effort classification and TTL-backed follow-up context;
|
|
218
|
+
- `routing` — model-only proxy hook for native Responses-only calls;
|
|
219
|
+
- `cli` - profile-resolving launcher for the packaged LiteLLM proxy config.
|
|
220
|
+
|
|
221
|
+
For standalone Python endpoint resolution and invocation helpers, use
|
|
222
|
+
[`dbx-tools-model`](../model). For the TypeScript local proxy, use
|
|
223
|
+
[`@dbx-tools/cli-model-proxy`](../../js/cli/model-proxy).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dbx-tools-litellm"
|
|
3
|
+
version = "0.6.92"
|
|
4
|
+
description = "LiteLLM custom provider for Databricks Model Serving with live fuzzy model resolution"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"databricks-sdk>=0.63.0",
|
|
9
|
+
"dbx-tools-model==0.6.92",
|
|
10
|
+
"diskcache>=5.6",
|
|
11
|
+
"litellm[proxy]>=1.83.14",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
Source = "https://github.com/reggie-db/dbx-tools/tree/main/packages/py/litellm"
|
|
16
|
+
|
|
17
|
+
[project.scripts]
|
|
18
|
+
dbx-litellm = "dbx_tools.litellm.cli:main"
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["uv_build>=0.11.28,<0.12.0"]
|
|
22
|
+
build-backend = "uv_build"
|
|
23
|
+
|
|
24
|
+
[tool.uv.build-backend]
|
|
25
|
+
module-name = "dbx_tools.litellm"
|
|
26
|
+
module-root = "src"
|
|
27
|
+
namespace = true
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# ~~ Generated by projen. To modify, edit .projenrc.js and run "bunx projen".
|
|
2
|
+
|
|
3
|
+
[project]
|
|
4
|
+
name = "dbx-tools-litellm"
|
|
5
|
+
version = "0.6.92"
|
|
6
|
+
description = "LiteLLM custom provider for Databricks Model Serving with live fuzzy model resolution"
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
requires-python = ">=3.10"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"databricks-sdk>=0.63.0",
|
|
11
|
+
"dbx-tools-model==0.6.92",
|
|
12
|
+
"diskcache>=5.6",
|
|
13
|
+
"litellm[proxy]>=1.83.14"
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
[project.urls]
|
|
17
|
+
Source = "https://github.com/reggie-db/dbx-tools/tree/main/packages/py/litellm"
|
|
18
|
+
|
|
19
|
+
[project.scripts]
|
|
20
|
+
dbx-litellm = "dbx_tools.litellm.cli:main"
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = [ "uv_build>=0.11.28,<0.12.0" ]
|
|
24
|
+
build-backend = "uv_build"
|
|
25
|
+
|
|
26
|
+
[tool.uv.build-backend]
|
|
27
|
+
module-name = "dbx_tools.litellm"
|
|
28
|
+
module-root = "src"
|
|
29
|
+
namespace = true
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""LiteLLM integration for Databricks model discovery and fuzzy routing."""
|
|
2
|
+
|
|
3
|
+
from .access_log import DbxAccessLogger, dbx_access_logger
|
|
4
|
+
from .backend import DatabricksLiteLLMBackend, require_profile
|
|
5
|
+
from .credentials import Credentials, DatabricksCredentials
|
|
6
|
+
from .provider import DbxCustomLLM, dbx_provider
|
|
7
|
+
from .reasoning import DbxAutoReasoning, ReasoningCache, dbx_auto_reasoning
|
|
8
|
+
from .routing import DbxResponsesRouter, dbx_responses_router
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"Credentials",
|
|
12
|
+
"DatabricksCredentials",
|
|
13
|
+
"DatabricksLiteLLMBackend",
|
|
14
|
+
"DbxAccessLogger",
|
|
15
|
+
"DbxAutoReasoning",
|
|
16
|
+
"DbxCustomLLM",
|
|
17
|
+
"DbxResponsesRouter",
|
|
18
|
+
"ReasoningCache",
|
|
19
|
+
"dbx_access_logger",
|
|
20
|
+
"dbx_auto_reasoning",
|
|
21
|
+
"dbx_provider",
|
|
22
|
+
"dbx_responses_router",
|
|
23
|
+
"require_profile",
|
|
24
|
+
]
|