From 126a80d643da5b2fb57748cdeadbb3804c1ce3b5 Mon Sep 17 00:00:00 2001 From: Jordan Hunt Date: Mon, 21 Apr 2025 12:40:54 -0700 Subject: [PATCH 1/2] fix --- app/lib/.server/chat.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/lib/.server/chat.ts b/app/lib/.server/chat.ts index e28fb1dc2..d5744cfbd 100644 --- a/app/lib/.server/chat.ts +++ b/app/lib/.server/chat.ts @@ -58,7 +58,9 @@ export async function chatAction({ request }: ActionFunctionArgs) { teamSlug: string; deploymentName: string | undefined; modelProvider: ModelProvider; - userApiKey: { preference: 'always' | 'quotaExhausted'; value?: string; openai?: string } | undefined; + userApiKey: + | { preference: 'always' | 'quotaExhausted'; value?: string; openai?: string; xai?: string; google?: string } + | undefined; }; const { messages, firstUserMessage, chatId, deploymentName, token, teamSlug } = body; @@ -100,14 +102,20 @@ export async function chatAction({ request }: ActionFunctionArgs) { if (body.modelProvider === 'Anthropic' || body.modelProvider === 'Bedrock') { userApiKey = body.userApiKey?.value; body.modelProvider = 'Anthropic'; - } else { + } else if (body.modelProvider === 'OpenAI') { userApiKey = body.userApiKey?.openai; + } else if (body.modelProvider === 'XAI') { + userApiKey = body.userApiKey?.xai; + } else if (body.modelProvider === 'Google') { + userApiKey = body.userApiKey?.google; } if (!userApiKey) { - const provider = body.modelProvider === 'OpenAI' ? 'OpenAI' : 'Anthropic'; - return new Response(JSON.stringify({ error: `Tried to use missing ${provider} API key. Set one in Settings!` }), { - status: 402, - }); + return new Response( + JSON.stringify({ error: `Tried to use missing ${body.modelProvider} API key. Set one in Settings!` }), + { + status: 402, + }, + ); } } logger.info(`Using model provider: ${body.modelProvider} (user API key: ${useUserApiKey})`); From e8675982c926331eb6605e262dda4a4079448d21 Mon Sep 17 00:00:00 2001 From: Jordan Hunt Date: Mon, 21 Apr 2025 12:44:03 -0700 Subject: [PATCH 2/2] nit --- app/lib/.server/chat.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/.server/chat.ts b/app/lib/.server/chat.ts index d5744cfbd..4a3cb1603 100644 --- a/app/lib/.server/chat.ts +++ b/app/lib/.server/chat.ts @@ -106,7 +106,7 @@ export async function chatAction({ request }: ActionFunctionArgs) { userApiKey = body.userApiKey?.openai; } else if (body.modelProvider === 'XAI') { userApiKey = body.userApiKey?.xai; - } else if (body.modelProvider === 'Google') { + } else { userApiKey = body.userApiKey?.google; } if (!userApiKey) {