fix(session): target native OpenRouter route
This commit is contained in:
parent
d79e8ba701
commit
3e8fc071ed
2 changed files with 24 additions and 8 deletions
|
|
@ -27,6 +27,7 @@ const DEFAULT_BASE_URL: Record<string, string> = {
|
||||||
"@ai-sdk/anthropic": "https://api.anthropic.com/v1",
|
"@ai-sdk/anthropic": "https://api.anthropic.com/v1",
|
||||||
"@ai-sdk/google": "https://generativelanguage.googleapis.com/v1beta",
|
"@ai-sdk/google": "https://generativelanguage.googleapis.com/v1beta",
|
||||||
"@ai-sdk/amazon-bedrock": "https://bedrock-runtime.us-east-1.amazonaws.com",
|
"@ai-sdk/amazon-bedrock": "https://bedrock-runtime.us-east-1.amazonaws.com",
|
||||||
|
"@openrouter/ai-sdk-provider": "https://openrouter.ai/api/v1",
|
||||||
}
|
}
|
||||||
|
|
||||||
const ROUTE: Record<string, string> = {
|
const ROUTE: Record<string, string> = {
|
||||||
|
|
@ -36,7 +37,7 @@ const ROUTE: Record<string, string> = {
|
||||||
"@ai-sdk/google": "gemini",
|
"@ai-sdk/google": "gemini",
|
||||||
"@ai-sdk/amazon-bedrock": "bedrock-converse",
|
"@ai-sdk/amazon-bedrock": "bedrock-converse",
|
||||||
"@ai-sdk/openai-compatible": "openai-compatible-chat",
|
"@ai-sdk/openai-compatible": "openai-compatible-chat",
|
||||||
"@openrouter/ai-sdk-provider": "openai-compatible-chat",
|
"@openrouter/ai-sdk-provider": "openrouter",
|
||||||
}
|
}
|
||||||
|
|
||||||
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
||||||
|
|
|
||||||
|
|
@ -199,13 +199,28 @@ describe("session.llm-native.request", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test("selects native routes from existing provider packages", () => {
|
test("selects native routes from existing provider packages", () => {
|
||||||
expect(LLMNative.model({ ...baseModel, api: { ...baseModel.api, npm: "@ai-sdk/anthropic" } }).route).toBe(
|
expect(
|
||||||
"anthropic-messages",
|
LLMNative.model({ ...baseModel, api: { ...baseModel.api, url: "", npm: "@ai-sdk/anthropic" } }),
|
||||||
)
|
).toMatchObject({
|
||||||
expect(LLMNative.model({ ...baseModel, api: { ...baseModel.api, npm: "@ai-sdk/google" } }).route).toBe("gemini")
|
route: "anthropic-messages",
|
||||||
expect(LLMNative.model({ ...baseModel, api: { ...baseModel.api, npm: "@ai-sdk/openai-compatible" } }).route).toBe(
|
baseURL: "https://api.anthropic.com/v1",
|
||||||
"openai-compatible-chat",
|
})
|
||||||
)
|
expect(LLMNative.model({ ...baseModel, api: { ...baseModel.api, url: "", npm: "@ai-sdk/google" } })).toMatchObject({
|
||||||
|
route: "gemini",
|
||||||
|
baseURL: "https://generativelanguage.googleapis.com/v1beta",
|
||||||
|
})
|
||||||
|
expect(
|
||||||
|
LLMNative.model({ ...baseModel, api: { ...baseModel.api, npm: "@ai-sdk/openai-compatible" } }),
|
||||||
|
).toMatchObject({
|
||||||
|
route: "openai-compatible-chat",
|
||||||
|
baseURL: "https://api.openai.com/v1",
|
||||||
|
})
|
||||||
|
expect(
|
||||||
|
LLMNative.model({ ...baseModel, api: { ...baseModel.api, url: "", npm: "@openrouter/ai-sdk-provider" } }),
|
||||||
|
).toMatchObject({
|
||||||
|
route: "openrouter",
|
||||||
|
baseURL: "https://openrouter.ai/api/v1",
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test("fails fast for unsupported provider packages", () => {
|
test("fails fast for unsupported provider packages", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue