mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 01:03:49 +00:00
Add Vercel AI Gateway support
This commit is contained in:
parent
907fa937e6
commit
164a69a601
12 changed files with 2254 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import type { Model } from "@mariozechner/pi-ai";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { parseModelPattern } from "../src/core/model-resolver.js";
|
||||
import { defaultModelPerProvider, findInitialModel, parseModelPattern } from "../src/core/model-resolver.js";
|
||||
|
||||
// Mock models for testing
|
||||
const mockModels: Model<"anthropic-messages">[] = [
|
||||
|
|
@ -200,3 +200,37 @@ describe("parseModelPattern", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("default model selection", () => {
|
||||
test("ai-gateway default is opus 4.5", () => {
|
||||
expect(defaultModelPerProvider["ai-gateway"]).toBe("anthropic/claude-opus-4.5");
|
||||
});
|
||||
|
||||
test("findInitialModel selects ai-gateway default when available", async () => {
|
||||
const aiGatewayModel: Model<"openai-completions"> = {
|
||||
id: "anthropic/claude-opus-4.5",
|
||||
name: "Claude Opus 4.5",
|
||||
api: "openai-completions",
|
||||
provider: "ai-gateway",
|
||||
baseUrl: "https://ai-gateway.vercel.sh/v1",
|
||||
reasoning: true,
|
||||
input: ["text", "image"],
|
||||
cost: { input: 5, output: 15, cacheRead: 0.5, cacheWrite: 5 },
|
||||
contextWindow: 200000,
|
||||
maxTokens: 8192,
|
||||
};
|
||||
|
||||
const registry = {
|
||||
getAvailable: async () => [aiGatewayModel],
|
||||
} as unknown as Parameters<typeof findInitialModel>[0]["modelRegistry"];
|
||||
|
||||
const result = await findInitialModel({
|
||||
scopedModels: [],
|
||||
isContinuing: false,
|
||||
modelRegistry: registry,
|
||||
});
|
||||
|
||||
expect(result.model?.provider).toBe("ai-gateway");
|
||||
expect(result.model?.id).toBe("anthropic/claude-opus-4.5");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue