mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🔑 refactor: Prioritize GOOGLE_KEY When GCP Service Key File Provided (#8150)
This commit is contained in:
parent
f869d772f7
commit
313539d1ed
1 changed files with 6 additions and 2 deletions
|
|
@ -98,8 +98,8 @@ export function getGoogleConfig(
|
|||
const serviceKey =
|
||||
typeof serviceKeyRaw === 'string' ? JSON.parse(serviceKeyRaw) : (serviceKeyRaw ?? {});
|
||||
|
||||
const project_id = serviceKey?.project_id ?? null;
|
||||
const apiKey = creds[AuthKeys.GOOGLE_API_KEY] ?? null;
|
||||
const project_id = !apiKey ? (serviceKey?.project_id ?? null) : null;
|
||||
|
||||
const reverseProxyUrl = options.reverseProxyUrl;
|
||||
const authHeader = options.authHeader;
|
||||
|
|
@ -128,7 +128,7 @@ export function getGoogleConfig(
|
|||
}
|
||||
|
||||
// If we have a GCP project => Vertex AI
|
||||
if (project_id && provider === Providers.VERTEXAI) {
|
||||
if (provider === Providers.VERTEXAI) {
|
||||
(llmConfig as VertexAIClientOptions).authOptions = {
|
||||
credentials: { ...serviceKey },
|
||||
projectId: project_id,
|
||||
|
|
@ -136,6 +136,10 @@ export function getGoogleConfig(
|
|||
(llmConfig as VertexAIClientOptions).location = process.env.GOOGLE_LOC || 'us-central1';
|
||||
} else if (apiKey && provider === Providers.GOOGLE) {
|
||||
llmConfig.apiKey = apiKey;
|
||||
} else {
|
||||
throw new Error(
|
||||
`Invalid credentials provided. Please provide either a valid API key or service account credentials for Google Cloud.`,
|
||||
);
|
||||
}
|
||||
|
||||
const shouldEnableThinking =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue