(workspaceId?: string | null)
| 78 | } |
| 79 | |
| 80 | async function resolveGeminiKey(workspaceId?: string | null): Promise<{ |
| 81 | apiKey: string |
| 82 | isBYOK: boolean |
| 83 | }> { |
| 84 | if (workspaceId) { |
| 85 | const byokResult = await getBYOKKey(workspaceId, 'google') |
| 86 | if (byokResult) { |
| 87 | logger.info('Using workspace BYOK key for Gemini embeddings') |
| 88 | return { apiKey: byokResult.apiKey, isBYOK: true } |
| 89 | } |
| 90 | } |
| 91 | if (env.GEMINI_API_KEY) { |
| 92 | return { apiKey: env.GEMINI_API_KEY, isBYOK: false } |
| 93 | } |
| 94 | try { |
| 95 | return { apiKey: getRotatingApiKey('gemini'), isBYOK: false } |
| 96 | } catch { |
| 97 | throw new Error( |
| 98 | 'GEMINI_API_KEY (or GEMINI_API_KEY_1/2/3 for rotation) must be configured for Gemini embeddings' |
| 99 | ) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | function buildOpenAIProvider(modelName: string, apiKey: string): ResolvedProvider['buildRequest'] { |
| 104 | return (inputs) => ({ |
no test coverage detected