From 92c66d2ce69ca81e14e406047412628cdc776342 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 20 May 2026 17:09:01 +0530 Subject: [PATCH] fix(client): defer GROQ_API_KEY environment validation to runtime to prevent build crash --- client/lib/aiSummarization.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/client/lib/aiSummarization.ts b/client/lib/aiSummarization.ts index bea43da..01ad74f 100644 --- a/client/lib/aiSummarization.ts +++ b/client/lib/aiSummarization.ts @@ -7,23 +7,19 @@ export interface CaseSummary { suggestedNextSteps: string[]; } -const GROQ_API_KEY = process.env.GROQ_API_KEY; - -if (!GROQ_API_KEY) { - throw new Error("GROQ_API_KEY environment variable is not set"); -} - -/** - * Call Groq API safely - */ async function callGroqAPI(prompt: string): Promise { + const apiKey = process.env.GROQ_API_KEY; + if (!apiKey) { + throw new Error("GROQ_API_KEY environment variable is not set"); + } + const response = await fetch( "https://api.groq.com/openai/v1/chat/completions", { method: "POST", headers: { "Content-Type": "application/json", - Authorization: `Bearer ${GROQ_API_KEY}`, + Authorization: `Bearer ${apiKey}`, }, body: JSON.stringify({ model: "llama-3.1-8b-instant",