Skip to content

Commit 1213c09

Browse files
committed
fix(providers): address SambaNova and Nebius review feedback
1 parent d9c72e2 commit 1213c09

1 file changed

Lines changed: 38 additions & 13 deletions

File tree

tests/sambanova-nebius-provider.test.ts

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ describe("SambaNova and Nebius providers", () => {
9090
dashboardUrl: PROVIDERS.sambanova.dashboardUrl,
9191
liveModels: true,
9292
preserveCustomDestination: true,
93+
apiKeyValidation: "unknown",
9394
parallelToolCalls: false,
95+
reasoningEfforts: [],
9496
modelDiscovery: {
9597
path: "models",
9698
maxResponseBytes: 131_072,
@@ -109,6 +111,7 @@ describe("SambaNova and Nebius providers", () => {
109111
liveModels: true,
110112
preserveCustomDestination: true,
111113
parallelToolCalls: false,
114+
reasoningEfforts: [],
112115
modelDiscovery: {
113116
path: "models",
114117
query: { verbose: "true" },
@@ -133,6 +136,7 @@ describe("SambaNova and Nebius providers", () => {
133136
baseUrl: provider.baseUrl,
134137
dashboardUrl: provider.dashboardUrl,
135138
liveModels: true,
139+
...(id === "sambanova" ? { apiKeyValidation: "unknown" } : {}),
136140
});
137141
expect(buildInitProviders().find(row => row.id === id)).toMatchObject({
138142
kind: "key",
@@ -151,34 +155,52 @@ describe("SambaNova and Nebius providers", () => {
151155
authMode: "key",
152156
liveModels: true,
153157
parallelToolCalls: false,
158+
reasoningEfforts: [],
154159
});
160+
expect(seed).not.toHaveProperty("apiKeyValidation");
155161
expect(seed).not.toHaveProperty("modelDiscovery");
156162
expect(seed).not.toHaveProperty("preserveCustomDestination");
157163
expect(KEY_LOGIN_PROVIDERS[id]).not.toHaveProperty("modelDiscovery");
158164
expect(KEY_LOGIN_PROVIDERS[id]).not.toHaveProperty("preserveCustomDestination");
159165
}
160166
});
161167

162-
test("lists and validates models through each registry-owned endpoint", async () => {
168+
test("builds each registry-owned models request and validates the authenticated Nebius catalog", async () => {
163169
for (const id of ["sambanova", "nebius"] as const) {
164170
const provider = PROVIDERS[id];
165171
expect(buildModelsRequest(providerConfig(id).providers[id]!, provider.key, id)).toEqual({
166172
url: provider.modelsUrl,
167173
headers: { Authorization: `Bearer ${provider.key}` },
168174
});
175+
}
169176

170-
globalThis.fetch = (async (input, init) => {
171-
expect(String(input)).toBe(provider.modelsUrl);
172-
expect(new Headers(init?.headers).get("authorization")).toBe(`Bearer ${provider.key}`);
173-
expect(init?.redirect).toBe("error");
174-
return new Response(provider.fixture, {
175-
status: 200,
176-
headers: { "content-type": "application/json" },
177-
});
178-
}) as typeof fetch;
177+
const provider = PROVIDERS.nebius;
178+
globalThis.fetch = (async (input, init) => {
179+
expect(String(input)).toBe(provider.modelsUrl);
180+
expect(new Headers(init?.headers).get("authorization")).toBe(`Bearer ${provider.key}`);
181+
expect(init?.redirect).toBe("error");
182+
return new Response(provider.fixture, {
183+
status: 200,
184+
headers: { "content-type": "application/json" },
185+
});
186+
}) as typeof fetch;
179187

180-
expect(await validateApiKey(id, KEY_LOGIN_PROVIDERS[id]!, provider.key)).toBe(true);
181-
}
188+
expect(await validateApiKey("nebius", KEY_LOGIN_PROVIDERS.nebius!, provider.key)).toBe(true);
189+
});
190+
191+
test("does not treat SambaNova's public model catalog as proof that a key is valid", async () => {
192+
let fetchCalled = false;
193+
globalThis.fetch = (async () => {
194+
fetchCalled = true;
195+
return new Response(SAMBANOVA_FIXTURE, { status: 200 });
196+
}) as typeof fetch;
197+
198+
expect(await validateApiKey(
199+
"sambanova",
200+
KEY_LOGIN_PROVIDERS.sambanova!,
201+
PROVIDERS.sambanova.key,
202+
)).toBe("unknown");
203+
expect(fetchCalled).toBe(false);
182204
});
183205

184206
test("filters Nebius mixed rows and preserves model metadata and native ids", async () => {
@@ -220,6 +242,7 @@ describe("SambaNova and Nebius providers", () => {
220242
expect(sambanovaModels[1]).toMatchObject({
221243
owned_by: "sambanova",
222244
contextWindow: 131_072,
245+
reasoningEfforts: [],
223246
});
224247
expect(nebiusModels.map(row => row.id)).toEqual([
225248
"meta-llama/Meta-Llama-3.1-8B-Instruct-fast",
@@ -230,6 +253,7 @@ describe("SambaNova and Nebius providers", () => {
230253
contextWindow: 131_072,
231254
inputModalities: ["text"],
232255
capabilities: ["function-calling", "json-mode"],
256+
reasoningEfforts: [],
233257
});
234258
expect(nebiusModels[1]).toMatchObject({
235259
contextWindow: 262_144,
@@ -265,14 +289,15 @@ describe("SambaNova and Nebius providers", () => {
265289
}],
266290
},
267291
stream: true,
268-
options: {},
292+
options: { reasoning: "high" },
269293
});
270294
const body = JSON.parse(String(request.body)) as Record<string, unknown>;
271295

272296
expect(request.url).toBe(`${PROVIDERS[providerId].baseUrl}/chat/completions`);
273297
expect(request.headers.Authorization).toBe(`Bearer ${PROVIDERS[providerId].key}`);
274298
expect(body.model).toBe(modelId);
275299
expect(body.parallel_tool_calls).toBe(false);
300+
expect(body).not.toHaveProperty("reasoning_effort");
276301
}
277302
});
278303

0 commit comments

Comments
 (0)