feat(gemini): add Gemini provider integration (#202)
* feat(gemini): add Gemini provider integration - Add gemini_config.rs module for .env file parsing - Extend AppType enum to support Gemini - Implement GeminiConfigEditor and GeminiFormFields components - Add GeminiIcon with standardized 1024x1024 viewBox - Add Gemini provider presets configuration - Update i18n translations for Gemini support - Extend ProviderService and McpService for Gemini * fix(gemini): resolve TypeScript errors, add i18n support, and fix MCP logic **Critical Fixes:** - Fix TS2741 errors in tests/msw/state.ts by adding missing Gemini type definitions - Fix ProviderCard.extractApiUrl to support GOOGLE_GEMINI_BASE_URL display - Add missing apps.gemini i18n keys (zh/en) for proper app name display - Fix MCP service Gemini cross-app duplication logic to prevent self-copy **Technical Details:** - tests/msw/state.ts: Add gemini default providers, current ID, and MCP config - ProviderCard.tsx: Check both ANTHROPIC_BASE_URL and GOOGLE_GEMINI_BASE_URL - services/mcp.rs: Skip Gemini in sync_other_side logic with unreachable!() guards - Run pnpm format to auto-fix code style issues **Verification:** - ✅ pnpm typecheck passes - ✅ pnpm format completed * feat(gemini): enhance authentication and config parsing - Add strict and lenient .env parsing modes - Implement PackyCode partner authentication detection - Support Google OAuth official authentication - Auto-configure security.auth.selectedType for PackyCode - Add comprehensive test coverage for all auth types - Update i18n for OAuth hints and Gemini config --------- Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
83
src/config/geminiProviderPresets.ts
Normal file
83
src/config/geminiProviderPresets.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import type { ProviderCategory } from "@/types";
|
||||
|
||||
export interface GeminiProviderPreset {
|
||||
name: string;
|
||||
websiteUrl: string;
|
||||
apiKeyUrl?: string;
|
||||
settingsConfig: object;
|
||||
baseURL?: string;
|
||||
model?: string;
|
||||
description?: string;
|
||||
category?: ProviderCategory;
|
||||
isPartner?: boolean;
|
||||
partnerPromotionKey?: string;
|
||||
endpointCandidates?: string[];
|
||||
}
|
||||
|
||||
export const geminiProviderPresets: GeminiProviderPreset[] = [
|
||||
{
|
||||
name: "Google",
|
||||
websiteUrl: "https://ai.google.dev/",
|
||||
apiKeyUrl: "https://aistudio.google.com/apikey",
|
||||
settingsConfig: {
|
||||
env: {
|
||||
GEMINI_MODEL: "gemini-2.5-pro",
|
||||
},
|
||||
},
|
||||
description: "Google 官方 Gemini API (OAuth)",
|
||||
category: "official",
|
||||
partnerPromotionKey: "google-official",
|
||||
model: "gemini-2.5-pro",
|
||||
},
|
||||
{
|
||||
name: "PackyCode",
|
||||
websiteUrl: "https://www.packyapi.com",
|
||||
apiKeyUrl: "https://www.packyapi.com/register?aff=cc-switch",
|
||||
settingsConfig: {
|
||||
env: {
|
||||
GOOGLE_GEMINI_BASE_URL: "https://www.packyapi.com",
|
||||
GEMINI_MODEL: "gemini-2.5-pro",
|
||||
},
|
||||
},
|
||||
baseURL: "https://www.packyapi.com",
|
||||
model: "gemini-2.5-pro",
|
||||
description: "PackyCode",
|
||||
category: "third_party",
|
||||
isPartner: true,
|
||||
partnerPromotionKey: "packycode",
|
||||
endpointCandidates: [
|
||||
"https://api-slb.packyapi.com",
|
||||
"https://www.packyapi.com",
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "自定义",
|
||||
websiteUrl: "",
|
||||
settingsConfig: {
|
||||
env: {
|
||||
GOOGLE_GEMINI_BASE_URL: "",
|
||||
GEMINI_MODEL: "gemini-2.5-pro",
|
||||
},
|
||||
},
|
||||
model: "gemini-2.5-pro",
|
||||
description: "自定义 Gemini API 端点",
|
||||
category: "custom",
|
||||
},
|
||||
];
|
||||
|
||||
export function getGeminiPresetByName(
|
||||
name: string,
|
||||
): GeminiProviderPreset | undefined {
|
||||
return geminiProviderPresets.find((preset) => preset.name === name);
|
||||
}
|
||||
|
||||
export function getGeminiPresetByUrl(
|
||||
url: string,
|
||||
): GeminiProviderPreset | undefined {
|
||||
if (!url) return undefined;
|
||||
return geminiProviderPresets.find(
|
||||
(preset) =>
|
||||
preset.baseURL &&
|
||||
url.toLowerCase().includes(preset.baseURL.toLowerCase()),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user