@dbx-tools/cli-model-proxy 0.3.24 → 0.3.25

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/cli.ts +24 -12
package/package.json CHANGED
@@ -18,16 +18,16 @@
18
18
  "@databricks/sdk-experimental": "^0.17.0",
19
19
  "commander": "^15.0.0",
20
20
  "tsx": "^4.23.0",
21
- "@dbx-tools/model": "0.3.24",
22
- "@dbx-tools/shared-model": "0.3.24",
23
- "@dbx-tools/shared-core": "0.3.24"
21
+ "@dbx-tools/model": "0.3.25",
22
+ "@dbx-tools/shared-model": "0.3.25",
23
+ "@dbx-tools/shared-core": "0.3.25"
24
24
  },
25
25
  "main": "index.ts",
26
26
  "license": "UNLICENSED",
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "version": "0.3.24",
30
+ "version": "0.3.25",
31
31
  "types": "index.ts",
32
32
  "type": "module",
33
33
  "exports": {
package/src/cli.ts CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  import { spawn } from "node:child_process";
22
22
  import type { Server } from "node:http";
23
- import { classify } from "@dbx-tools/shared-model";
23
+ import { classify, type ServingEndpointSummary } from "@dbx-tools/shared-model";
24
24
  import { Command, CommanderError } from "commander";
25
25
 
26
26
  import { DatabricksBackend, type BackendOptions } from "./backend";
@@ -157,15 +157,7 @@ export function buildProgram(): Command {
157
157
  const opts = globalOpts<CommonOpts & { chat?: boolean }>(command);
158
158
  const backend = await DatabricksBackend.create(backendOptions(opts));
159
159
  const endpoints = await backend.models();
160
- // Enrich each endpoint with a derived `capabilities` object so consumers
161
- // filter on capability rather than re-deriving it from raw `task`/`class`
162
- // strings. `chat` = OpenAI chat/completions + Responses (what an agent
163
- // like Codex needs); `embedding` = vector endpoints; `tools` = whether the
164
- // endpoint supports function/tool calls (all chat endpoints here do).
165
- const enriched = endpoints.map((endpoint) => ({
166
- ...endpoint,
167
- capabilities: classify.endpointCapabilities(endpoint),
168
- }));
160
+ const enriched = endpoints.map(enrichEndpoint);
169
161
  const out = opts.chat ? enriched.filter((e) => e.capabilities.chat) : enriched;
170
162
  process.stdout.write(`${JSON.stringify(out, null, 2)}\n`);
171
163
  });
@@ -178,13 +170,33 @@ export function buildProgram(): Command {
178
170
  ).action(async (query: string[], _local: CommonOpts, command: Command) => {
179
171
  const opts = globalOpts<CommonOpts>(command);
180
172
  const backend = await DatabricksBackend.create(backendOptions(opts));
181
- const resolved = await backend.resolve(query.join(" "));
182
- process.stdout.write(`${JSON.stringify(resolved, null, 2)}\n`);
173
+ const search = query.join(" ");
174
+ const resolved = await backend.resolve(search);
175
+ // Same shape as one `models` entry when matched; null when nothing in the
176
+ // catalogue scores within the threshold (caller can fall back to the query).
177
+ if (!resolved.matched) {
178
+ process.stdout.write("null\n");
179
+ return;
180
+ }
181
+ const endpoint = (await backend.models()).find((e) => e.name === resolved.modelId);
182
+ process.stdout.write(
183
+ `${JSON.stringify(endpoint ? enrichEndpoint(endpoint) : null, null, 2)}\n`,
184
+ );
183
185
  });
184
186
 
185
187
  return program;
186
188
  }
187
189
 
190
+ /** One `models` / `resolve` list entry: endpoint summary + derived capabilities. */
191
+ function enrichEndpoint(endpoint: ServingEndpointSummary) {
192
+ return {
193
+ ...endpoint,
194
+ // `chat` = OpenAI chat/completions + Responses; `embedding` = vectors;
195
+ // `tools` = function/tool calls (every chat endpoint here).
196
+ capabilities: classify.endpointCapabilities(endpoint),
197
+ };
198
+ }
199
+
188
200
  /** Parse `argv` and run the matching command. Throws {@link CommanderError} on flag errors. */
189
201
  export async function runCli(argv: string[]): Promise<void> {
190
202
  await buildProgram().parseAsync(argv);