fix(ai): type Anthropic probes by catalog providers

This commit is contained in:
Armin Ronacher
2026-07-14 12:29:38 +02:00
parent adfac437bb
commit 92ffae5228
2 changed files with 8 additions and 8 deletions
@@ -1,6 +1,6 @@
import { Type } from "typebox"; import { Type } from "typebox";
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { complete, getModels, getProviders } from "../src/compat.ts"; import { type BuiltinProvider, complete, getModels, getProviders } from "../src/compat.ts";
import { getEnvApiKey } from "../src/env-api-keys.ts"; import { getEnvApiKey } from "../src/env-api-keys.ts";
import type { Api, KnownProvider, Model, ProviderStreamOptions, Tool } from "../src/types.ts"; import type { Api, KnownProvider, Model, ProviderStreamOptions, Tool } from "../src/types.ts";
import { resolveApiKey } from "./oauth.ts"; import { resolveApiKey } from "./oauth.ts";
@@ -19,7 +19,7 @@ const echoTool: Tool<typeof echoToolSchema> = {
interface AnthropicEagerE2ECase { interface AnthropicEagerE2ECase {
name: string; name: string;
provider: KnownProvider; provider: BuiltinProvider;
model: Model<"anthropic-messages">; model: Model<"anthropic-messages">;
apiKey: string | undefined; apiKey: string | undefined;
} }
@@ -31,7 +31,7 @@ function getE2EApiKey(provider: KnownProvider): string | undefined {
return getEnvApiKey(provider); return getEnvApiKey(provider);
} }
function getAnthropicMessagesModels(provider: KnownProvider): Model<"anthropic-messages">[] { function getAnthropicMessagesModels(provider: BuiltinProvider): Model<"anthropic-messages">[] {
const models = getModels(provider) as Model<Api>[]; const models = getModels(provider) as Model<Api>[];
return models.filter((model) => model.api === "anthropic-messages") as Model<"anthropic-messages">[]; return models.filter((model) => model.api === "anthropic-messages") as Model<"anthropic-messages">[];
} }
@@ -64,7 +64,7 @@ function getProbePriority(model: Model<"anthropic-messages">): number {
} }
function selectOneCasePerProvider(cases: AnthropicEagerE2ECase[]): AnthropicEagerE2ECase[] { function selectOneCasePerProvider(cases: AnthropicEagerE2ECase[]): AnthropicEagerE2ECase[] {
const byProvider = new Map<KnownProvider, AnthropicEagerE2ECase[]>(); const byProvider = new Map<BuiltinProvider, AnthropicEagerE2ECase[]>();
for (const testCase of cases) { for (const testCase of cases) {
const providerCases = byProvider.get(testCase.provider) ?? []; const providerCases = byProvider.get(testCase.provider) ?? [];
providerCases.push(testCase); providerCases.push(testCase);
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest"; import { describe, expect, it } from "vitest";
import { complete, getModels, getProviders } from "../src/compat.ts"; import { type BuiltinProvider, complete, getModels, getProviders } from "../src/compat.ts";
import { getEnvApiKey } from "../src/env-api-keys.ts"; import { getEnvApiKey } from "../src/env-api-keys.ts";
import type { Api, KnownProvider, Model, ProviderStreamOptions } from "../src/types.ts"; import type { Api, KnownProvider, Model, ProviderStreamOptions } from "../src/types.ts";
import { resolveApiKey } from "./oauth.ts"; import { resolveApiKey } from "./oauth.ts";
@@ -8,7 +8,7 @@ const githubCopilotToken = await resolveApiKey("github-copilot");
interface AnthropicLongCacheRetentionE2ECase { interface AnthropicLongCacheRetentionE2ECase {
name: string; name: string;
provider: KnownProvider; provider: BuiltinProvider;
model: Model<"anthropic-messages">; model: Model<"anthropic-messages">;
apiKey: string | undefined; apiKey: string | undefined;
} }
@@ -20,7 +20,7 @@ function getE2EApiKey(provider: KnownProvider): string | undefined {
return getEnvApiKey(provider); return getEnvApiKey(provider);
} }
function getAnthropicMessagesModels(provider: KnownProvider): Model<"anthropic-messages">[] { function getAnthropicMessagesModels(provider: BuiltinProvider): Model<"anthropic-messages">[] {
const models = getModels(provider) as Model<Api>[]; const models = getModels(provider) as Model<Api>[];
return models.filter((model) => model.api === "anthropic-messages") as Model<"anthropic-messages">[]; return models.filter((model) => model.api === "anthropic-messages") as Model<"anthropic-messages">[];
} }
@@ -51,7 +51,7 @@ function getProbePriority(model: Model<"anthropic-messages">): number {
} }
function selectOneCasePerProvider(cases: AnthropicLongCacheRetentionE2ECase[]): AnthropicLongCacheRetentionE2ECase[] { function selectOneCasePerProvider(cases: AnthropicLongCacheRetentionE2ECase[]): AnthropicLongCacheRetentionE2ECase[] {
const byProvider = new Map<KnownProvider, AnthropicLongCacheRetentionE2ECase[]>(); const byProvider = new Map<BuiltinProvider, AnthropicLongCacheRetentionE2ECase[]>();
for (const testCase of cases) { for (const testCase of cases) {
const providerCases = byProvider.get(testCase.provider) ?? []; const providerCases = byProvider.get(testCase.provider) ?? [];
providerCases.push(testCase); providerCases.push(testCase);