@dbx-tools/model 0.1.17 → 0.1.19

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @dbx-tools/node-model
1
+ # @dbx-tools/model
2
2
 
3
3
  Workspace-aware Databricks Model Serving selection.
4
4
 
@@ -49,7 +49,7 @@ endpoint:
49
49
 
50
50
  ```ts
51
51
  import { WorkspaceClient } from "@databricks/sdk-experimental";
52
- import { resolve } from "@dbx-tools/node-model";
52
+ import { resolve } from "@dbx-tools/model";
53
53
 
54
54
  const client = new WorkspaceClient({});
55
55
  const host = String(await client.config.getHost());
@@ -72,7 +72,7 @@ so operators can tell whether a request used the intended model policy.
72
72
  ## Build A Model Picker
73
73
 
74
74
  ```ts
75
- import { resolve } from "@dbx-tools/node-model";
75
+ import { resolve } from "@dbx-tools/model";
76
76
 
77
77
  const ranked = await resolve.searchModels(client, host, {
78
78
  search: "opus",
@@ -91,7 +91,7 @@ When you already have endpoint summaries, use the pure resolver functions from
91
91
  `resolve` and `serving` without another workspace call:
92
92
 
93
93
  ```ts
94
- import { resolve, serving } from "@dbx-tools/node-model";
94
+ import { resolve, serving } from "@dbx-tools/model";
95
95
 
96
96
  const endpoints = await serving.listServingEndpoints(client, host);
97
97
  const ranked = resolve.rankModels(endpoints, { search: "sonnet", limit: 3 });
@@ -108,7 +108,7 @@ when the requested class is `embedding`.
108
108
  ## List And Cache Serving Endpoints
109
109
 
110
110
  ```ts
111
- import { serving } from "@dbx-tools/node-model";
111
+ import { serving } from "@dbx-tools/model";
112
112
 
113
113
  const endpoints = await serving.listServingEndpoints(client, host, {
114
114
  ttlMs: 5 * 60_000,
@@ -140,7 +140,7 @@ exact endpoint ids.
140
140
  ## Use Static Fallbacks
141
141
 
142
142
  ```ts
143
- import { classes, fallback } from "@dbx-tools/node-model";
143
+ import { classes, fallback } from "@dbx-tools/model";
144
144
  import { model } from "@dbx-tools/shared-model";
145
145
 
146
146
  const cls = classes.parseModelClass("chat-fast") ?? model.ModelClass.ChatFast;
@@ -161,5 +161,5 @@ policy decisions; fallbacks are a last resort.
161
161
  - `fallback` - static fallback model ids per class.
162
162
 
163
163
  The AppKit-Mastra integration uses this package through
164
- [`@dbx-tools/node-appkit-mastra`](../appkit-mastra); the local OpenAI-compatible
164
+ [`@dbx-tools/appkit-mastra`](../appkit-mastra); the local OpenAI-compatible
165
165
  gateway uses it through [`@dbx-tools/model-proxy`](../../cli/model-proxy).
package/package.json CHANGED
@@ -13,13 +13,16 @@
13
13
  "dependencies": {
14
14
  "@databricks/appkit": "^0.43.0",
15
15
  "fuse.js": "^7.4.2",
16
- "@dbx-tools/appkit": "0.1.17",
17
- "@dbx-tools/shared-core": "0.1.17",
18
- "@dbx-tools/shared-model": "0.1.17"
16
+ "@dbx-tools/shared-core": "0.1.19",
17
+ "@dbx-tools/appkit": "0.1.19",
18
+ "@dbx-tools/shared-model": "0.1.19"
19
19
  },
20
20
  "main": "index.ts",
21
21
  "license": "UNLICENSED",
22
- "version": "0.1.17",
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "version": "0.1.19",
23
26
  "types": "index.ts",
24
27
  "type": "module",
25
28
  "exports": {
package/src/resolve.ts CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  type RankedModel,
26
26
  type ServingEndpointSummary,
27
27
  } from "@dbx-tools/shared-model";
28
+ import { object } from "@dbx-tools/shared-core";
28
29
 
29
30
  import { CHAT_CLASS_ORDER, classesAtOrBelow, MODEL_CLASS_ORDER } from "./classes";
30
31
  import { FALLBACK_MODEL_IDS, modelsForClass } from "./fallback";
@@ -240,10 +241,9 @@ export function resolveModel(
240
241
  if (top) return { modelId: top.endpoint.name, source };
241
242
 
242
243
  // Live catalogue yielded nothing in range: walk the static floor.
243
- const floor =
244
- input.modelClass !== undefined
245
- ? dedupe([...modelsForClass(input.modelClass), ...FALLBACK_MODEL_IDS])
246
- : dedupe([...(input.fallbacks ?? []), ...FALLBACK_MODEL_IDS]);
244
+ const floorSource =
245
+ input.modelClass !== undefined ? modelsForClass(input.modelClass) : (input.fallbacks ?? []);
246
+ const floor = object.sequence(floorSource).concat(FALLBACK_MODEL_IDS).distinct().toArray();
247
247
  return { modelId: pickFirstAvailable(floor, endpoints), source };
248
248
  }
249
249
 
@@ -257,11 +257,6 @@ function buildQuery(input: ResolveModelInput, search: string | undefined): Model
257
257
  };
258
258
  }
259
259
 
260
- /** Drop duplicate ids while preserving first-seen order. */
261
- function dedupe(ids: readonly string[]): string[] {
262
- return [...new Set(ids)];
263
- }
264
-
265
260
  /**
266
261
  * Find the first id in `candidates` whose endpoint is present in `endpoints`.
267
262
  * Returns the top candidate when the workspace has none of them so callers