@dbx-tools/model 0.9.153 → 0.9.157
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.
- package/index.ts +23 -12
- package/lib/index.d.ts +23 -12
- package/lib/index.js +21 -12
- package/lib/scripts/generate-metadata.js +2 -2
- package/lib/src/_cache.js +2 -2
- package/lib/src/_metadata-generator.d.ts +1 -1
- package/lib/src/_metadata-generator.js +1 -1
- package/lib/src/_ranking.d.ts +1 -1
- package/lib/src/_ranking.js +22 -27
- package/lib/src/classes.d.ts +1 -1
- package/lib/src/classes.js +2 -2
- package/lib/src/classify.d.ts +1 -1
- package/lib/src/classify.js +2 -2
- package/lib/src/fallback.d.ts +1 -1
- package/lib/src/fallback.js +2 -2
- package/lib/src/metadata-cache.d.ts +1 -1
- package/lib/src/metadata-cache.js +5 -6
- package/lib/src/{_metadata-contract.d.ts → metadata-contract.d.ts} +1 -1
- package/lib/src/metadata-contract.js +13 -0
- package/lib/src/metadata.d.ts +3 -4
- package/lib/src/metadata.js +5 -7
- package/lib/src/model-catalog.js +5 -6
- package/lib/src/model-client.d.ts +1 -1
- package/lib/src/model-client.js +10 -12
- package/lib/src/policy.d.ts +1 -1
- package/lib/src/policy.js +2 -2
- package/lib/src/reasoning-translation.js +7 -10
- package/lib/src/resolve.d.ts +1 -3
- package/lib/src/resolve.js +2 -3
- package/lib/src/{_retirement.d.ts → retirement.d.ts} +1 -1
- package/lib/src/retirement.js +59 -0
- package/lib/src/{_selection.d.ts → selection.d.ts} +1 -1
- package/lib/src/selection.js +89 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -113
- package/src/_cache.ts +1 -1
- package/src/_metadata-generator.ts +1 -1
- package/src/_ranking.ts +21 -26
- package/src/classes.ts +1 -1
- package/src/classify.ts +1 -1
- package/src/fallback.ts +1 -1
- package/src/metadata-cache.ts +4 -5
- package/src/{_metadata-contract.ts → metadata-contract.ts} +1 -1
- package/src/metadata.ts +20 -34
- package/src/model-catalog.ts +4 -6
- package/src/model-client.ts +9 -11
- package/src/policy.ts +1 -1
- package/src/reasoning-translation.ts +6 -9
- package/src/resolve.ts +6 -9
- package/src/{_retirement.ts → retirement.ts} +2 -2
- package/src/{_selection.ts → selection.ts} +3 -3
- package/exports.ts +0 -1
- package/lib/exports.d.ts +0 -1
- package/lib/exports.js +0 -2
- package/lib/src/_metadata-contract.js +0 -13
- package/lib/src/_retirement.js +0 -59
- package/lib/src/_selection.js +0 -89
package/package.json
CHANGED
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@databricks/appkit": "0.81.0",
|
|
28
|
-
"@dbx-tools/appkit": "^0.9.
|
|
29
|
-
"@dbx-tools/auth": "^0.9.
|
|
30
|
-
"@dbx-tools/cache": "^0.9.
|
|
31
|
-
"@dbx-tools/shared-auth": "^0.9.
|
|
32
|
-
"@dbx-tools/shared-core": "^0.9.
|
|
33
|
-
"@dbx-tools/shared-model": "^0.9.
|
|
28
|
+
"@dbx-tools/appkit": "^0.9.157",
|
|
29
|
+
"@dbx-tools/auth": "^0.9.157",
|
|
30
|
+
"@dbx-tools/cache": "^0.9.157",
|
|
31
|
+
"@dbx-tools/shared-auth": "^0.9.157",
|
|
32
|
+
"@dbx-tools/shared-core": "^0.9.157",
|
|
33
|
+
"@dbx-tools/shared-model": "^0.9.157",
|
|
34
34
|
"cheerio": "^1.2.0",
|
|
35
35
|
"fuse.js": "^7.4.2"
|
|
36
36
|
},
|
|
@@ -45,62 +45,10 @@
|
|
|
45
45
|
"types": "./lib/index.d.ts",
|
|
46
46
|
"default": "./lib/index.js"
|
|
47
47
|
},
|
|
48
|
-
"./bindings": {
|
|
49
|
-
"types": "./lib/src/bindings.d.ts",
|
|
50
|
-
"default": "./lib/src/bindings.js"
|
|
51
|
-
},
|
|
52
|
-
"./classes": {
|
|
53
|
-
"types": "./lib/src/classes.d.ts",
|
|
54
|
-
"default": "./lib/src/classes.js"
|
|
55
|
-
},
|
|
56
|
-
"./classify": {
|
|
57
|
-
"types": "./lib/src/classify.d.ts",
|
|
58
|
-
"default": "./lib/src/classify.js"
|
|
59
|
-
},
|
|
60
|
-
"./fallback": {
|
|
61
|
-
"types": "./lib/src/fallback.d.ts",
|
|
62
|
-
"default": "./lib/src/fallback.js"
|
|
63
|
-
},
|
|
64
|
-
"./invoke": {
|
|
65
|
-
"types": "./lib/src/invoke.d.ts",
|
|
66
|
-
"default": "./lib/src/invoke.js"
|
|
67
|
-
},
|
|
68
|
-
"./metadata-cache": {
|
|
69
|
-
"types": "./lib/src/metadata-cache.d.ts",
|
|
70
|
-
"default": "./lib/src/metadata-cache.js"
|
|
71
|
-
},
|
|
72
|
-
"./metadata": {
|
|
73
|
-
"types": "./lib/src/metadata.d.ts",
|
|
74
|
-
"default": "./lib/src/metadata.js"
|
|
75
|
-
},
|
|
76
|
-
"./model-catalog": {
|
|
77
|
-
"types": "./lib/src/model-catalog.d.ts",
|
|
78
|
-
"default": "./lib/src/model-catalog.js"
|
|
79
|
-
},
|
|
80
|
-
"./model-client": {
|
|
81
|
-
"types": "./lib/src/model-client.d.ts",
|
|
82
|
-
"default": "./lib/src/model-client.js"
|
|
83
|
-
},
|
|
84
|
-
"./policy": {
|
|
85
|
-
"types": "./lib/src/policy.d.ts",
|
|
86
|
-
"default": "./lib/src/policy.js"
|
|
87
|
-
},
|
|
88
|
-
"./reasoning-translation": {
|
|
89
|
-
"types": "./lib/src/reasoning-translation.d.ts",
|
|
90
|
-
"default": "./lib/src/reasoning-translation.js"
|
|
91
|
-
},
|
|
92
|
-
"./resolve": {
|
|
93
|
-
"types": "./lib/src/resolve.d.ts",
|
|
94
|
-
"default": "./lib/src/resolve.js"
|
|
95
|
-
},
|
|
96
|
-
"./*": {
|
|
97
|
-
"types": "./lib/src/*/index.d.ts",
|
|
98
|
-
"default": "./lib/src/*/index.js"
|
|
99
|
-
},
|
|
100
48
|
"./package.json": "./package.json"
|
|
101
49
|
}
|
|
102
50
|
},
|
|
103
|
-
"version": "0.9.
|
|
51
|
+
"version": "0.9.157",
|
|
104
52
|
"types": "./lib/index.d.ts",
|
|
105
53
|
"dbxToolsConfig": {
|
|
106
54
|
"tags": [
|
|
@@ -113,64 +61,11 @@
|
|
|
113
61
|
"types": "./lib/index.d.ts",
|
|
114
62
|
"default": "./lib/index.js"
|
|
115
63
|
},
|
|
116
|
-
"./bindings": {
|
|
117
|
-
"types": "./lib/src/bindings.d.ts",
|
|
118
|
-
"default": "./lib/src/bindings.js"
|
|
119
|
-
},
|
|
120
|
-
"./classes": {
|
|
121
|
-
"types": "./lib/src/classes.d.ts",
|
|
122
|
-
"default": "./lib/src/classes.js"
|
|
123
|
-
},
|
|
124
|
-
"./classify": {
|
|
125
|
-
"types": "./lib/src/classify.d.ts",
|
|
126
|
-
"default": "./lib/src/classify.js"
|
|
127
|
-
},
|
|
128
|
-
"./fallback": {
|
|
129
|
-
"types": "./lib/src/fallback.d.ts",
|
|
130
|
-
"default": "./lib/src/fallback.js"
|
|
131
|
-
},
|
|
132
|
-
"./invoke": {
|
|
133
|
-
"types": "./lib/src/invoke.d.ts",
|
|
134
|
-
"default": "./lib/src/invoke.js"
|
|
135
|
-
},
|
|
136
|
-
"./metadata-cache": {
|
|
137
|
-
"types": "./lib/src/metadata-cache.d.ts",
|
|
138
|
-
"default": "./lib/src/metadata-cache.js"
|
|
139
|
-
},
|
|
140
|
-
"./metadata": {
|
|
141
|
-
"types": "./lib/src/metadata.d.ts",
|
|
142
|
-
"default": "./lib/src/metadata.js"
|
|
143
|
-
},
|
|
144
|
-
"./model-catalog": {
|
|
145
|
-
"types": "./lib/src/model-catalog.d.ts",
|
|
146
|
-
"default": "./lib/src/model-catalog.js"
|
|
147
|
-
},
|
|
148
|
-
"./model-client": {
|
|
149
|
-
"types": "./lib/src/model-client.d.ts",
|
|
150
|
-
"default": "./lib/src/model-client.js"
|
|
151
|
-
},
|
|
152
|
-
"./policy": {
|
|
153
|
-
"types": "./lib/src/policy.d.ts",
|
|
154
|
-
"default": "./lib/src/policy.js"
|
|
155
|
-
},
|
|
156
|
-
"./reasoning-translation": {
|
|
157
|
-
"types": "./lib/src/reasoning-translation.d.ts",
|
|
158
|
-
"default": "./lib/src/reasoning-translation.js"
|
|
159
|
-
},
|
|
160
|
-
"./resolve": {
|
|
161
|
-
"types": "./lib/src/resolve.d.ts",
|
|
162
|
-
"default": "./lib/src/resolve.js"
|
|
163
|
-
},
|
|
164
|
-
"./*": {
|
|
165
|
-
"types": "./lib/src/*/index.d.ts",
|
|
166
|
-
"default": "./lib/src/*/index.js"
|
|
167
|
-
},
|
|
168
64
|
"./package.json": "./package.json"
|
|
169
65
|
},
|
|
170
66
|
"files": [
|
|
171
|
-
"index
|
|
67
|
+
"index*.ts",
|
|
172
68
|
"src",
|
|
173
|
-
"exports.ts",
|
|
174
69
|
"lib"
|
|
175
70
|
],
|
|
176
71
|
"//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"bunx projen\"."
|
package/src/_cache.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
ModelRateLimitsSnapshot,
|
|
7
7
|
ReasoningModelsSnapshot,
|
|
8
8
|
RetiredModelsSnapshot,
|
|
9
|
-
} from "./
|
|
9
|
+
} from "./metadata-contract.ts";
|
|
10
10
|
import { inheritsNativeWebSearch, modelSearchQuery } from "./policy.ts";
|
|
11
11
|
import {
|
|
12
12
|
parseReasoning,
|
package/src/_ranking.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isRecord, trimToUndefined } from "@dbx-tools/shared-core";
|
|
2
2
|
import {
|
|
3
3
|
ModelClass as ModelClassValues,
|
|
4
4
|
type ModelClass as ModelClassType,
|
|
5
5
|
type ModelQuery,
|
|
6
6
|
type RankedModel,
|
|
7
7
|
type ServingEndpointSummary,
|
|
8
|
-
} from "@dbx-tools/shared-model
|
|
9
|
-
import { toModelDisplayName } from "@dbx-tools/shared-model
|
|
8
|
+
} from "@dbx-tools/shared-model";
|
|
9
|
+
import { toModelDisplayName } from "@dbx-tools/shared-model";
|
|
10
10
|
import Fuse from "fuse.js";
|
|
11
11
|
|
|
12
|
-
import { modelStatusFor } from "./_retirement.ts";
|
|
13
12
|
import { classesAtOrBelow, CHAT_CLASS_ORDER, MODEL_CLASS_ORDER } from "./classes.ts";
|
|
14
13
|
import {
|
|
15
14
|
classifyEndpoints,
|
|
@@ -23,6 +22,7 @@ import {
|
|
|
23
22
|
modelReasoningEfforts,
|
|
24
23
|
modelServiceNames,
|
|
25
24
|
} from "./policy.ts";
|
|
25
|
+
import { modelStatusFor } from "./retirement.ts";
|
|
26
26
|
|
|
27
27
|
type ModelClass = ModelClassType;
|
|
28
28
|
const ModelClass = ModelClassValues;
|
|
@@ -201,49 +201,46 @@ export function classifyEndpointClasses(
|
|
|
201
201
|
export function normalizeEndpoints(endpoints: readonly unknown[]): ServingEndpointSummary[] {
|
|
202
202
|
const summaries = endpoints.flatMap((value) => {
|
|
203
203
|
const endpoint = record(value);
|
|
204
|
-
const name =
|
|
204
|
+
const name = trimToUndefined(endpoint.name);
|
|
205
205
|
if (!name) return [];
|
|
206
206
|
const entities = arrayValue(record(endpoint.config).served_entities).map(record);
|
|
207
207
|
const identities = [
|
|
208
208
|
name,
|
|
209
209
|
...entities.flatMap((entity) =>
|
|
210
210
|
[
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
211
|
+
trimToUndefined(entity.entity_name),
|
|
212
|
+
trimToUndefined(record(entity.foundation_model).name),
|
|
213
|
+
trimToUndefined(record(entity.external_model).name),
|
|
214
214
|
].filter((identity): identity is string => Boolean(identity)),
|
|
215
215
|
),
|
|
216
216
|
];
|
|
217
217
|
const modelServiceName = entities
|
|
218
218
|
.map(
|
|
219
219
|
(entity) =>
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
trimToUndefined(record(entity.foundation_model).name) ??
|
|
221
|
+
trimToUndefined(entity.entity_name),
|
|
222
222
|
)
|
|
223
223
|
.find(Boolean);
|
|
224
224
|
const foundationModels = entities.map((entity) => record(entity.foundation_model));
|
|
225
225
|
const family =
|
|
226
|
-
foundationModels
|
|
227
|
-
|
|
228
|
-
.find(Boolean) ?? identities.map(modelFamily).find(Boolean);
|
|
226
|
+
foundationModels.map((model) => trimToUndefined(model.model_class)).find(Boolean) ??
|
|
227
|
+
identities.map(modelFamily).find(Boolean);
|
|
229
228
|
const reasoningEfforts =
|
|
230
229
|
identities.map(modelReasoningEfforts).sort((left, right) => right.length - left.length)[0] ??
|
|
231
230
|
[];
|
|
232
231
|
const profile = entities.map(modelProfile).find(Boolean);
|
|
233
232
|
const capabilitiesRecord = record(endpoint.capabilities);
|
|
234
233
|
const foundationDescription = foundationModels
|
|
235
|
-
.map((model) =>
|
|
234
|
+
.map((model) => trimToUndefined(model.description))
|
|
236
235
|
.find(Boolean);
|
|
237
|
-
const description =
|
|
236
|
+
const description = trimToUndefined(endpoint.description) ?? foundationDescription;
|
|
238
237
|
const summary: ServingEndpointSummary = {
|
|
239
238
|
name,
|
|
240
239
|
displayName: toModelDisplayName(name, providedDisplayName(endpoint, entities)),
|
|
241
240
|
...(family ? { family } : {}),
|
|
242
|
-
...(
|
|
243
|
-
|
|
244
|
-
:
|
|
245
|
-
...(stringUtils.trimToUndefined(record(endpoint.state).ready)
|
|
246
|
-
? { state: stringUtils.trimToUndefined(record(endpoint.state).ready) }
|
|
241
|
+
...(trimToUndefined(endpoint.task) ? { task: trimToUndefined(endpoint.task) } : {}),
|
|
242
|
+
...(trimToUndefined(record(endpoint.state).ready)
|
|
243
|
+
? { state: trimToUndefined(record(endpoint.state).ready) }
|
|
247
244
|
: {}),
|
|
248
245
|
...(description ? { description } : {}),
|
|
249
246
|
supportsTools:
|
|
@@ -336,21 +333,19 @@ function providedDisplayName(
|
|
|
336
333
|
): string | undefined {
|
|
337
334
|
for (const tag of arrayValue(endpoint.tags).map(record)) {
|
|
338
335
|
if (!["display_name", "displayName", "name"].includes(String(tag.key))) continue;
|
|
339
|
-
const value =
|
|
336
|
+
const value = trimToUndefined(tag.value);
|
|
340
337
|
if (value) return value;
|
|
341
338
|
}
|
|
342
339
|
return (
|
|
343
340
|
entities
|
|
344
|
-
.map((entity) =>
|
|
341
|
+
.map((entity) => trimToUndefined(record(entity.foundation_model).display_name))
|
|
345
342
|
.find(Boolean) ??
|
|
346
|
-
entities
|
|
347
|
-
.map((entity) => stringUtils.trimToUndefined(record(entity.external_model).name))
|
|
348
|
-
.find(Boolean)
|
|
343
|
+
entities.map((entity) => trimToUndefined(record(entity.external_model).name)).find(Boolean)
|
|
349
344
|
);
|
|
350
345
|
}
|
|
351
346
|
|
|
352
347
|
function record(value: unknown): Record<string, unknown> {
|
|
353
|
-
return
|
|
348
|
+
return isRecord(value) ? value : {};
|
|
354
349
|
}
|
|
355
350
|
|
|
356
351
|
function arrayValue(value: unknown): unknown[] {
|
package/src/classes.ts
CHANGED
package/src/classify.ts
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
ModelClass as ModelClassValues,
|
|
33
33
|
type ModelClass as ModelClassType,
|
|
34
34
|
type ServingEndpointSummary,
|
|
35
|
-
} from "@dbx-tools/shared-model
|
|
35
|
+
} from "@dbx-tools/shared-model";
|
|
36
36
|
|
|
37
37
|
type ModelClass = ModelClassType;
|
|
38
38
|
const ModelClass = ModelClassValues;
|
package/src/fallback.ts
CHANGED
package/src/metadata-cache.ts
CHANGED
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { createCache, getOrSet } from "@dbx-tools/cache
|
|
8
|
-
import
|
|
9
|
-
import * as log from "@dbx-tools/shared-core/log";
|
|
7
|
+
import { createCache, getOrSet } from "@dbx-tools/cache";
|
|
8
|
+
import { toError, log } from "@dbx-tools/shared-core";
|
|
10
9
|
|
|
11
10
|
import { modelMetadataCache } from "./_cache.ts";
|
|
12
|
-
import { MODEL_METADATA_TTL_MS } from "./
|
|
11
|
+
import { MODEL_METADATA_TTL_MS } from "./metadata-contract.ts";
|
|
13
12
|
|
|
14
13
|
const logger = log.logger("model/metadata-cache");
|
|
15
14
|
|
|
@@ -78,7 +77,7 @@ export function createMetadataCache<T>(
|
|
|
78
77
|
} catch (error) {
|
|
79
78
|
logger.warn("metadata cache refresh failed; using cached or committed value", {
|
|
80
79
|
key: options.key,
|
|
81
|
-
error:
|
|
80
|
+
error: toError(error),
|
|
82
81
|
});
|
|
83
82
|
staleRefreshFailed = previous !== undefined;
|
|
84
83
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ModelRateLimits } from "@dbx-tools/shared-model
|
|
1
|
+
import type { ModelRateLimits } from "@dbx-tools/shared-model";
|
|
2
2
|
|
|
3
3
|
/** One day, matching the refresh cadence of Databricks model documentation. */
|
|
4
4
|
export const MODEL_METADATA_TTL_MS = 24 * 60 * 60 * 1000;
|
package/src/metadata.ts
CHANGED
|
@@ -11,38 +11,20 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
|
-
import
|
|
14
|
+
import { memoize } from "@dbx-tools/shared-core";
|
|
15
15
|
import type {
|
|
16
16
|
ModelCapabilities,
|
|
17
17
|
ModelMetadata,
|
|
18
18
|
ModelRateLimits,
|
|
19
19
|
ServingEndpointSummary,
|
|
20
|
-
} from "@dbx-tools/shared-model
|
|
20
|
+
} from "@dbx-tools/shared-model";
|
|
21
21
|
|
|
22
|
-
import {
|
|
23
|
-
MODEL_METADATA_TTL_MS,
|
|
24
|
-
MODEL_RATE_LIMITS_URL,
|
|
25
|
-
OPENAI_RESPONSES_MODELS_URL,
|
|
26
|
-
QUERY_REASON_MODELS_URL,
|
|
27
|
-
RETIRED_MODELS_URL,
|
|
28
|
-
WEB_SEARCH_MODELS_URL,
|
|
29
|
-
type ModelCapabilitiesSnapshot,
|
|
30
|
-
type ModelCapabilityCatalogue,
|
|
31
|
-
type ModelRateLimitsSnapshot,
|
|
32
|
-
type ReasoningModelsSnapshot,
|
|
33
|
-
} from "./_metadata-contract.ts";
|
|
34
22
|
import {
|
|
35
23
|
parseModelCapabilities,
|
|
36
24
|
parseModelRateLimits,
|
|
37
25
|
parseReasoningModels,
|
|
38
26
|
parseRetiredModels,
|
|
39
27
|
} from "./_metadata-generator.ts";
|
|
40
|
-
import {
|
|
41
|
-
COMMITTED_RETIRED_MODELS,
|
|
42
|
-
modelStatusFor,
|
|
43
|
-
replaceRetiredModelNames,
|
|
44
|
-
RETIRED_MODELS_GENERATED_AT,
|
|
45
|
-
} from "./_retirement.ts";
|
|
46
28
|
import capabilitiesSnapshotJson from "./generated/model-capabilities.json" with { type: "json" };
|
|
47
29
|
import rateLimitsSnapshotJson from "./generated/model-rate-limits.json" with { type: "json" };
|
|
48
30
|
import reasoningSnapshotJson from "./generated/model-reasoning.json" with { type: "json" };
|
|
@@ -52,6 +34,17 @@ import {
|
|
|
52
34
|
mergePreferFreshRecord,
|
|
53
35
|
type MetadataCache,
|
|
54
36
|
} from "./metadata-cache.ts";
|
|
37
|
+
import {
|
|
38
|
+
MODEL_RATE_LIMITS_URL,
|
|
39
|
+
OPENAI_RESPONSES_MODELS_URL,
|
|
40
|
+
QUERY_REASON_MODELS_URL,
|
|
41
|
+
RETIRED_MODELS_URL,
|
|
42
|
+
WEB_SEARCH_MODELS_URL,
|
|
43
|
+
type ModelCapabilitiesSnapshot,
|
|
44
|
+
type ModelCapabilityCatalogue,
|
|
45
|
+
type ModelRateLimitsSnapshot,
|
|
46
|
+
type ReasoningModelsSnapshot,
|
|
47
|
+
} from "./metadata-contract.ts";
|
|
55
48
|
import { inheritsNativeWebSearch, isFoundationModelIdentity, modelSearchQuery } from "./policy.ts";
|
|
56
49
|
import {
|
|
57
50
|
defaultReasoningLevels,
|
|
@@ -62,15 +55,12 @@ import {
|
|
|
62
55
|
type ReasoningModelCatalogue,
|
|
63
56
|
uniqueReasoningLevels,
|
|
64
57
|
} from "./reasoning-translation.ts";
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
RETIRED_MODELS_URL,
|
|
72
|
-
WEB_SEARCH_MODELS_URL,
|
|
73
|
-
};
|
|
58
|
+
import {
|
|
59
|
+
COMMITTED_RETIRED_MODELS,
|
|
60
|
+
modelStatusFor,
|
|
61
|
+
replaceRetiredModelNames,
|
|
62
|
+
RETIRED_MODELS_GENERATED_AT,
|
|
63
|
+
} from "./retirement.ts";
|
|
74
64
|
|
|
75
65
|
const capabilitiesSnapshot = capabilitiesSnapshotJson as ModelCapabilitiesSnapshot;
|
|
76
66
|
const rateLimitsSnapshot = rateLimitsSnapshotJson as ModelRateLimitsSnapshot;
|
|
@@ -156,9 +146,7 @@ const learnedReasoningCache = createMetadataCache<
|
|
|
156
146
|
|
|
157
147
|
let liveIndex: MetadataIndex | undefined;
|
|
158
148
|
|
|
159
|
-
const metadataIndex =
|
|
160
|
-
() => liveIndex ?? buildIndexFromCommitted(),
|
|
161
|
-
);
|
|
149
|
+
const metadataIndex = memoize<MetadataIndex>(() => liveIndex ?? buildIndexFromCommitted());
|
|
162
150
|
|
|
163
151
|
function buildIndexFromCommitted(): MetadataIndex {
|
|
164
152
|
return buildIndex({
|
|
@@ -277,8 +265,6 @@ async function peekOrFallback<T>(cache: MetadataCache<T>, fallback: T): Promise<
|
|
|
277
265
|
return cache.get().catch(() => fallback);
|
|
278
266
|
}
|
|
279
267
|
|
|
280
|
-
export { modelStatusFor, retiredModelNames } from "./_retirement.ts";
|
|
281
|
-
|
|
282
268
|
/** Return the committed reasoning-effort catalogue. Cached per process. */
|
|
283
269
|
export function reasoningModelCatalogue(): ReasoningModelCatalogue {
|
|
284
270
|
return metadataIndex().reasoning;
|
package/src/model-catalog.ts
CHANGED
|
@@ -23,21 +23,19 @@
|
|
|
23
23
|
|
|
24
24
|
import { createHash } from "node:crypto";
|
|
25
25
|
import { appkit } from "@dbx-tools/appkit";
|
|
26
|
-
import { deleteCachedValue, getOrSet } from "@dbx-tools/cache
|
|
27
|
-
import {
|
|
26
|
+
import { deleteCachedValue, getOrSet } from "@dbx-tools/cache";
|
|
27
|
+
import { log, toError } from "@dbx-tools/shared-core";
|
|
28
28
|
import {
|
|
29
|
-
model,
|
|
30
29
|
type ResolvedModel,
|
|
31
30
|
type ResolveModelOptions,
|
|
32
31
|
type ScoredEndpoint,
|
|
33
32
|
type ServingEndpointSummary,
|
|
33
|
+
ModelClass,
|
|
34
34
|
} from "@dbx-tools/shared-model";
|
|
35
35
|
|
|
36
36
|
import { modelCatalogueCache } from "./_cache.ts";
|
|
37
37
|
import { classifyEndpointClasses, normalizeEndpoints, rankEndpoints } from "./_ranking.ts";
|
|
38
38
|
|
|
39
|
-
const { ModelClass } = model;
|
|
40
|
-
|
|
41
39
|
const logger = log.logger("model/serving");
|
|
42
40
|
|
|
43
41
|
/**
|
|
@@ -189,7 +187,7 @@ async function pingEmbeddingDimension(
|
|
|
189
187
|
logger.warn("embedding ping returned no vector", { name });
|
|
190
188
|
return undefined;
|
|
191
189
|
} catch (err) {
|
|
192
|
-
logger.warn("embedding ping failed", { name, error:
|
|
190
|
+
logger.warn("embedding ping failed", { name, error: toError(err) });
|
|
193
191
|
return undefined;
|
|
194
192
|
}
|
|
195
193
|
}
|
package/src/model-client.ts
CHANGED
|
@@ -12,12 +12,10 @@ import {
|
|
|
12
12
|
createAuthClient,
|
|
13
13
|
type AuthClient,
|
|
14
14
|
type DatabricksAuthDependencies,
|
|
15
|
-
} from "@dbx-tools/auth
|
|
16
|
-
import { listProfiles as listAuthProfiles } from "@dbx-tools/auth
|
|
15
|
+
} from "@dbx-tools/auth";
|
|
16
|
+
import { listProfiles as listAuthProfiles } from "@dbx-tools/auth";
|
|
17
17
|
import type { DatabricksProfileSummary } from "@dbx-tools/shared-auth";
|
|
18
|
-
import
|
|
19
|
-
import * as log from "@dbx-tools/shared-core/log";
|
|
20
|
-
import * as object from "@dbx-tools/shared-core/object";
|
|
18
|
+
import { toError, log, isRecord } from "@dbx-tools/shared-core";
|
|
21
19
|
import {
|
|
22
20
|
ModelClass,
|
|
23
21
|
type ModelMetadata,
|
|
@@ -26,10 +24,9 @@ import {
|
|
|
26
24
|
type ResolvedModelSelection,
|
|
27
25
|
type ResolveModelInput,
|
|
28
26
|
type ServingEndpointSummary,
|
|
29
|
-
} from "@dbx-tools/shared-model
|
|
27
|
+
} from "@dbx-tools/shared-model";
|
|
30
28
|
|
|
31
29
|
import { normalizeEndpoints } from "./_ranking.ts";
|
|
32
|
-
import { lookupModels, resolveModel } from "./_selection.ts";
|
|
33
30
|
import {
|
|
34
31
|
aiGatewayCodexResponsesUrl,
|
|
35
32
|
chatCompletionsUrl,
|
|
@@ -38,6 +35,7 @@ import {
|
|
|
38
35
|
} from "./invoke.ts";
|
|
39
36
|
import { hydrateModelMetadata, modelMetadataFor } from "./metadata.ts";
|
|
40
37
|
import { modelServingApi, prefersSystemModelService, systemModelService } from "./policy.ts";
|
|
38
|
+
import { lookupModels, resolveModel } from "./selection.ts";
|
|
41
39
|
|
|
42
40
|
const logger = log.logger("model/client");
|
|
43
41
|
|
|
@@ -269,7 +267,7 @@ class DefaultModelClient implements ModelClient {
|
|
|
269
267
|
private async fetchCatalogue(): Promise<readonly ServingEndpointSummary[]> {
|
|
270
268
|
const startedAt = Date.now();
|
|
271
269
|
const response = await this.client.request("/api/2.0/serving-endpoints");
|
|
272
|
-
if (!
|
|
270
|
+
if (!isRecord(response) || !Array.isArray(response.endpoints)) {
|
|
273
271
|
throw new Error("Databricks serving-endpoints response is missing an endpoints array");
|
|
274
272
|
}
|
|
275
273
|
const endpoints = await this.measureEmbeddingDimensions(normalizeEndpoints(response.endpoints));
|
|
@@ -302,7 +300,7 @@ class DefaultModelClient implements ModelClient {
|
|
|
302
300
|
} catch (error) {
|
|
303
301
|
logger.warn("embedding dimension probe failed", {
|
|
304
302
|
model: endpoint.name,
|
|
305
|
-
error:
|
|
303
|
+
error: toError(error),
|
|
306
304
|
});
|
|
307
305
|
return endpoint;
|
|
308
306
|
}
|
|
@@ -312,9 +310,9 @@ class DefaultModelClient implements ModelClient {
|
|
|
312
310
|
}
|
|
313
311
|
|
|
314
312
|
function embeddingDimension(value: unknown): number | undefined {
|
|
315
|
-
if (!
|
|
313
|
+
if (!isRecord(value) || !Array.isArray(value.data)) return undefined;
|
|
316
314
|
const first = value.data[0];
|
|
317
|
-
if (!
|
|
315
|
+
if (!isRecord(first) || !Array.isArray(first.embedding)) return undefined;
|
|
318
316
|
return first.embedding.length > 0 ? first.embedding.length : undefined;
|
|
319
317
|
}
|
|
320
318
|
|
package/src/policy.ts
CHANGED
|
@@ -21,9 +21,7 @@
|
|
|
21
21
|
* @module
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import {
|
|
25
|
-
import { isRecord } from "@dbx-tools/shared-core/object";
|
|
26
|
-
import * as stringUtils from "@dbx-tools/shared-core/string-utils";
|
|
24
|
+
import { parseRecord, parse, isRecord, trimToNull } from "@dbx-tools/shared-core";
|
|
27
25
|
import Fuse from "fuse.js";
|
|
28
26
|
|
|
29
27
|
import { modelFamily, modelSearchQuery } from "./policy.ts";
|
|
@@ -393,8 +391,7 @@ export function adaptRequestReasoning(
|
|
|
393
391
|
/** Normalize labels for alias lookup (`Extra High` → `extra-high`). */
|
|
394
392
|
export function normalizeReasoningToken(value: string): string {
|
|
395
393
|
return (
|
|
396
|
-
|
|
397
|
-
.trimToNull(value)
|
|
394
|
+
trimToNull(value)
|
|
398
395
|
?.toLowerCase()
|
|
399
396
|
.replace(/[_\s]+/g, "-")
|
|
400
397
|
.replace(/[^a-z0-9-]/g, "")
|
|
@@ -438,7 +435,7 @@ function catalogueKeysFor(model: string): string[] {
|
|
|
438
435
|
}
|
|
439
436
|
|
|
440
437
|
function modelCatalogueKey(name: string): string | undefined {
|
|
441
|
-
const trimmed =
|
|
438
|
+
const trimmed = trimToNull(name);
|
|
442
439
|
if (!trimmed) return undefined;
|
|
443
440
|
return (
|
|
444
441
|
modelSearchQuery(trimmed)?.replaceAll(" ", "-") ??
|
|
@@ -483,14 +480,14 @@ function collectTextLeaves(value: unknown, depth = 0): string[] {
|
|
|
483
480
|
}
|
|
484
481
|
|
|
485
482
|
function tryUnwrapJson(text: string): unknown {
|
|
486
|
-
const asRecord =
|
|
483
|
+
const asRecord = parseRecord(text);
|
|
487
484
|
if (asRecord) return asRecord;
|
|
488
|
-
const parsed =
|
|
485
|
+
const parsed = parse(text);
|
|
489
486
|
if (parsed !== undefined) return parsed;
|
|
490
487
|
if (text.includes('\\"') || text.includes("\\n")) {
|
|
491
488
|
const unescaped = text.replace(/\\"/g, '"').replace(/\\n/g, "\n").replace(/\\\\/g, "\\");
|
|
492
489
|
if (unescaped !== text) {
|
|
493
|
-
const nested =
|
|
490
|
+
const nested = parse(unescaped);
|
|
494
491
|
if (nested !== undefined) return nested;
|
|
495
492
|
}
|
|
496
493
|
}
|
package/src/resolve.ts
CHANGED
|
@@ -13,20 +13,17 @@ import type {
|
|
|
13
13
|
ServingEndpointSummary,
|
|
14
14
|
} from "@dbx-tools/shared-model";
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
lookupModels,
|
|
18
|
-
rankModelId,
|
|
19
|
-
resolveModel,
|
|
20
|
-
type ModelSelectionPolicyOptions,
|
|
21
|
-
} from "./_selection.ts";
|
|
22
16
|
import {
|
|
23
17
|
listServingEndpoints,
|
|
24
18
|
type ListServingEndpointsOptions,
|
|
25
19
|
type WorkspaceClientLike,
|
|
26
20
|
} from "./model-catalog.ts";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
import {
|
|
22
|
+
lookupModels,
|
|
23
|
+
rankModelId,
|
|
24
|
+
resolveModel,
|
|
25
|
+
type ModelSelectionPolicyOptions,
|
|
26
|
+
} from "./selection.ts";
|
|
30
27
|
|
|
31
28
|
/** Intent plus catalogue cache controls passed to {@link selectModel}. */
|
|
32
29
|
export interface SelectModelInput extends ResolveModelInput {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Lightweight model retirement state shared by discovery and metadata caches. */
|
|
2
|
-
import type { ModelStatus, ServingEndpointSummary } from "@dbx-tools/shared-model
|
|
2
|
+
import type { ModelStatus, ServingEndpointSummary } from "@dbx-tools/shared-model";
|
|
3
3
|
|
|
4
|
-
import type { RetiredModelsSnapshot } from "./_metadata-contract.ts";
|
|
5
4
|
import retiredModelsSnapshotJson from "./generated/retired-models.json" with { type: "json" };
|
|
5
|
+
import type { RetiredModelsSnapshot } from "./metadata-contract.ts";
|
|
6
6
|
|
|
7
7
|
const snapshot = retiredModelsSnapshotJson as RetiredModelsSnapshot;
|
|
8
8
|
const RETIRED_MODEL_PREFIXES = new Set([
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import { sequence } from "@dbx-tools/shared-core";
|
|
7
7
|
import type {
|
|
8
8
|
ModelQuery,
|
|
9
9
|
RankedModel,
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
ResolveModelInput,
|
|
13
13
|
ResolveModelOptions,
|
|
14
14
|
ServingEndpointSummary,
|
|
15
|
-
} from "@dbx-tools/shared-model
|
|
15
|
+
} from "@dbx-tools/shared-model";
|
|
16
16
|
|
|
17
17
|
import { rankEndpoints } from "./_ranking.ts";
|
|
18
18
|
import { FALLBACK_MODEL_IDS, modelsForClass } from "./fallback.ts";
|
|
@@ -92,7 +92,7 @@ export function resolveModel(
|
|
|
92
92
|
|
|
93
93
|
const floorSource =
|
|
94
94
|
input.modelClass !== undefined ? modelsForClass(input.modelClass) : (input.fallbacks ?? []);
|
|
95
|
-
const floor =
|
|
95
|
+
const floor = sequence(floorSource).concat(FALLBACK_MODEL_IDS).distinct().toArray();
|
|
96
96
|
if (input.requiresTools) {
|
|
97
97
|
const available = new Set(
|
|
98
98
|
endpoints.filter(endpointSupportsTools).map((endpoint) => endpoint.name),
|