mirror of
https://github.com/coder/coder.git
synced 2026-10-29 17:44:33 +08:00
fix: add Gemini/Google provider support to AI Bridge session page (#26374)
Fixes https://github.com/coder/internal/issues/1576
This commit is contained in:
@@ -6,6 +6,7 @@ import { cn } from "#/utils/cn";
|
||||
// See official model naming docs:
|
||||
// - Anthropic: https://docs.anthropic.com/en/docs/about-claude/models/all-models
|
||||
// - OpenAI: https://platform.openai.com/docs/models
|
||||
// - Google: https://ai.google.dev/gemini-api/docs/models
|
||||
function inferModelFamily(model: string): string {
|
||||
const modelFamily = model.toLowerCase();
|
||||
// Anthropic model families
|
||||
@@ -28,6 +29,10 @@ function inferModelFamily(model: string): string {
|
||||
) {
|
||||
return "openai";
|
||||
}
|
||||
// Google model families (gemini-*, gemma-*)
|
||||
if (modelFamily.includes("gemini") || modelFamily.includes("gemma")) {
|
||||
return "gemini";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
@@ -55,6 +60,13 @@ export const AIBridgeModelIcon = ({
|
||||
className={cn(iconClassName, className)}
|
||||
/>
|
||||
);
|
||||
case "gemini":
|
||||
return (
|
||||
<ExternalImage
|
||||
src="/icon/gemini.svg"
|
||||
className={cn(iconClassName, className)}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<CircleQuestionMarkIcon
|
||||
|
||||
@@ -25,6 +25,27 @@ export const AIBridgeProviderIcon = ({
|
||||
className={cn(iconClassName, className)}
|
||||
/>
|
||||
);
|
||||
case "google":
|
||||
return (
|
||||
<ExternalImage
|
||||
src="/icon/google.svg"
|
||||
className={cn(iconClassName, className)}
|
||||
/>
|
||||
);
|
||||
case "azure":
|
||||
return (
|
||||
<ExternalImage
|
||||
src="/icon/azure.svg"
|
||||
className={cn(iconClassName, className)}
|
||||
/>
|
||||
);
|
||||
case "bedrock":
|
||||
return (
|
||||
<ExternalImage
|
||||
src="/icon/aws.svg"
|
||||
className={cn(iconClassName, className)}
|
||||
/>
|
||||
);
|
||||
case "copilot":
|
||||
return (
|
||||
<ExternalImage
|
||||
@@ -32,6 +53,13 @@ export const AIBridgeProviderIcon = ({
|
||||
className={cn(iconClassName, className)}
|
||||
/>
|
||||
);
|
||||
case "vercel":
|
||||
return (
|
||||
<ExternalImage
|
||||
src="/icon/vercel.svg"
|
||||
className={cn(iconClassName, className)}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<CircleQuestionMarkIcon
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getProviderDisplayName } from "./utils";
|
||||
|
||||
describe("getProviderDisplayName", () => {
|
||||
it.each([
|
||||
["anthropic", "Anthropic"],
|
||||
["openai", "OpenAI"],
|
||||
["google", "Google"],
|
||||
["azure", "Azure OpenAI"],
|
||||
["bedrock", "AWS Bedrock"],
|
||||
["copilot", "GitHub Copilot"],
|
||||
["openai-compat", "OpenAI-compatible"],
|
||||
["openrouter", "OpenRouter"],
|
||||
["vercel", "Vercel"],
|
||||
])("maps known provider %s to %s", (input, expected) => {
|
||||
expect(getProviderDisplayName(input)).toBe(expected);
|
||||
});
|
||||
|
||||
it("capitalizes unknown provider names", () => {
|
||||
expect(getProviderDisplayName("custom")).toBe("Custom");
|
||||
expect(getProviderDisplayName("some-provider")).toBe("Some-provider");
|
||||
});
|
||||
|
||||
it("returns Unknown for empty string", () => {
|
||||
expect(getProviderDisplayName("")).toBe("Unknown");
|
||||
});
|
||||
});
|
||||
@@ -18,9 +18,25 @@ export const getProviderDisplayName = (provider: string) => {
|
||||
return "Anthropic";
|
||||
case "openai":
|
||||
return "OpenAI";
|
||||
case "google":
|
||||
return "Google";
|
||||
case "azure":
|
||||
return "Azure OpenAI";
|
||||
case "bedrock":
|
||||
return "AWS Bedrock";
|
||||
case "copilot":
|
||||
return "Github";
|
||||
default:
|
||||
return "Unknown";
|
||||
return "GitHub Copilot";
|
||||
case "openai-compat":
|
||||
return "OpenAI-compatible";
|
||||
case "openrouter":
|
||||
return "OpenRouter";
|
||||
case "vercel":
|
||||
return "Vercel";
|
||||
default: {
|
||||
if (!provider) {
|
||||
return "Unknown";
|
||||
}
|
||||
return provider.charAt(0).toUpperCase() + provider.slice(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user