Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat: add Groq API integration for ultra-fast AI inference

Gabriel Stein993e8930a12f
diff --git a/preload.js b/preload.js
index 6f6944764..2c2f3c695 100644
--- a/preload.js
+++ b/preload.js
@@ -112,7 +112,11 @@ contextBridge.exposeInMainWorld("electronAPI", {
// Gemini API
getGeminiKey: () => ipcRenderer.invoke("get-gemini-key"),
saveGeminiKey: (key) => ipcRenderer.invoke("save-gemini-key", key),
-
+
+ // Groq API
+ getGroqKey: () => ipcRenderer.invoke("get-groq-key"),
+ saveGroqKey: (key) => ipcRenderer.invoke("save-groq-key", key),
+
// Local reasoning
processLocalReasoning: (text, modelId, agentName, config) =>
ipcRenderer.invoke("process-local-reasoning", text, modelId, agentName, config),
diff --git a/src/components/AIModelSelectorEnhanced.tsx b/src/components/AIModelSelectorEnhanced.tsx
index f0e4ac7a6..f714836ab 100644
--- a/src/components/AIModelSelectorEnhanced.tsx
+++ b/src/components/AIModelSelectorEnhanced.tsx
@@ -22,6 +22,7 @@ const PROVIDER_ICON_MAP: Record<string, string> = {
openai: 'openai',
anthropic: 'anthropic',
gemini: 'gemini',
+ groq: 'groq',
llama: 'llama',
mistral: 'mistral',
qwen: 'qwen',
@@ -69,6 +70,8 @@ interface AIModelSelectorEnhancedProps {
setAnthropicApiKey: (key: string) => void;
geminiApiKey: string;
setGeminiApiKey: (key: string) => void;
+ groqApiKey: string;
+ setGroqApiKey: (key: string) => void;
pasteFromClipboard: (setter: (value: string) => void) => void;
showAlertDialog: (dialog: { title: string; description: string }) => void;
}
@@ -89,6 +92,7 @@ const ProviderIcon = ({ provider }: { provider: string }) => {
case 'openai': return <Brain className={iconClass} />;
case 'anthropic': return <Zap className={iconClass} />;
case 'gemini': return <Globe className={iconClass} />;
+ case 'groq': return <Zap className={iconClass} />; // Lightning fast inference
// Local providers
case 'qwen': return <Brain className={iconClass} />;
case 'mistral': return <Zap className={iconClass} />;
@@ -133,6 +137,8 @@ export default function AIModelSelectorEnhanced({
setAnthropicApiKey,
geminiApiKey,
setGeminiApiKey,
+ groqApiKey,
+ setGroqApiKey,
pasteFromClipboard,
showAlertDialog,
}: AIModelSelectorEnhancedProps) {
@@ -178,7 +184,16 @@ export default function AIModelSelectorEnhanced({
const rawBase = (baseOverride ?? cloudReasoningBaseUrl) || '';
const normalizedBase = normalizeBaseUrl(rawBase);
+ console.log('[loadRemoteModels] Called with:', {
+ baseOverride,
+ force,
+ rawBase,
+ normalizedBase,
+ cloudReasoningBaseUrl
+ });
+
if (!normalizedBase) {
+ console.log('[loadRemoteModels] No normalized base, clearing models');
if (isMountedRef.current) {
setCustomModelsLoading(false);
setCustomModelsError(null);
@@ -188,10 +203,12 @@ export default function AIModelSelectorEnhanced({
}
if (!force && lastLoadedBaseRef.current === normalizedBase) {
+ console.log('[loadRemoteModels] Already loaded this base, skipping');
return;
}
if (!force && pendingBaseRef.current === normalizedBase) {
+ console.log('[loadRemoteModels] Already pending for this base, skipping');
return;
}
@@ -216,7 +233,14 @@ export default function AIModelSelectorEnhanced({
? keyFromState
: await window.electronAPI?.getOpenAIKey?.();
+ console.log('[loadRemoteModels] API Key status:', {
+ hasKeyFromState: !!keyFromState,
+ hasKeyFromElectron: !!apiKey,
+ keyLength: apiKey?.length || 0
+ });
+
if (!normalizedBase.includes('://')) {
+ console.error('[loadRemoteModels] Invalid URL - missing protocol:', normalizedBase);
if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
setCustomModelsError('Enter a full base URL including protocol (e.g. https://server/v1).');
setCustomModelsLoading(false);
@@ -227,6 +251,7 @@ export default function AIModelSelectorEnhanced({
// Security: Only allow HTTPS endpoints (except localhost for development)
const isLocalhost = normalizedBase.includes('://localhost') || normalizedBase.includes('://127.0.0.1');
if (!normalizedBase.startsWith('https://') && !isLocalhost) {
+ console.error('[loadRemoteModels] Non-HTTPS endpoint rejected:', normalizedBase);
if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
setCustomModelsError('Only HTTPS endpoints are allowed (except localhost for testing).');
setCustomModelsLoading(false);
@@ -239,11 +264,16 @@ export default function AIModelSelectorEnhanced({
headers.Authorization = `Bearer ${apiKey}`;
}
- const response = await fetch(buildApiUrl(normalizedBase, '/models'), {
+ const modelsUrl = buildApiUrl(normalizedBase, '/models');
+ console.log('[loadRemoteModels] Fetching models from:', modelsUrl, 'with headers:', headers);
+
+ const response = await fetch(modelsUrl, {
method: 'GET',
headers,
});
+ console.log('[loadRemoteModels] Response status:', response.status, response.statusText);
+
if (!response.ok) {
const errorText = await response.text().catch(() => '');
const summary = errorText
@@ -253,12 +283,16 @@ export default function AIModelSelectorEnhanced({
}
const payload = await response.json().catch(() => ({}));
+ console.log('[loadRemoteModels] Payload received:', payload);
+
const rawModels = Array.isArray(payload?.data)
? payload.data
: Array.isArray(payload?.models)
? payload.models
: [];
+ console.log('[loadRemoteModels] Raw models count:', rawModels.length);
+
const mappedModels = (rawModels as Array<any>)
.map((item) => {
const value = item?.id || item?.name;
@@ -278,18 +312,23 @@ export default function AIModelSelectorEnhanced({
})
.filter(Boolean) as CloudModelOption[];
+ console.log('[loadRemoteModels] Mapped models:', mappedModels.length, mappedModels.slice(0, 3));
+
if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
+ console.log('[loadRemoteModels] Setting custom model options:', mappedModels.length);
setCustomModelOptions(mappedModels);
if (
mappedModels.length > 0 &&
!mappedModels.some((model) => model.value === reasoningModel)
) {
+ console.log('[loadRemoteModels] Auto-selecting first model:', mappedModels[0].value);
setReasoningModel(mappedModels[0].value);
}
setCustomModelsError(null);
lastLoadedBaseRef.current = normalizedBase;
}
} catch (error) {
+ console.error('[loadRemoteModels] Error:', error);
if (isMountedRef.current && latestReasoningBaseRef.current === normalizedBase) {
const message =
(error as Error).message || 'Unable to load models from endpoint.';
@@ -325,7 +364,7 @@ export default function AIModelSelectorEnhanced({
return customModelOptions;
}, [isCustomBaseDirty, customModelOptions]);
- const cloudProviders = ['openai', 'anthropic', 'gemini', 'custom'];
+ const cloudProviders = ['openai', 'anthropic', 'gemini', 'groq', 'custom'];
const localProviders = modelRegistry.getAllProviders().map((p) => p.id);
const openaiModelOptions = useMemo<CloudModelOption[]>(() => {
@@ -523,8 +562,9 @@ export default function AIModelSelectorEnhanced({
const getProviderColor = (provider: string) => {
const colors: Record<string, string> = {
'openai': 'green',
- 'anthropic': 'purple',
+ 'anthropic': 'purple',
'gemini': 'blue',
+ 'groq': 'orange', // Fast and fiery like Groq
'qwen': 'indigo',
'mistral': 'orange',
'llama': 'blue',
@@ -796,6 +836,31 @@ export default function AIModelSelectorEnhanced({
</p>
</div>
)}
+
+ {selectedCloudProvider === 'groq' && (
+ <div className="space-y-3">
+ <h4 className="font-medium text-gray-900">API Configuration</h4>
+ <div className="flex gap-2">
+ <Input
+ type="password"
+ placeholder="gsk_..."
+ value={groqApiKey}
+ onChange={(e) => setGroqApiKey(e.target.value)}
+ className="flex-1 text-sm"
+ />
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => pasteFromClipboard(setGroqApiKey)}
+ >
+ Paste
+ </Button>
+ </div>
+ <p className="text-xs text-gray-600">
+ Get your API key from console.groq.com
+ </p>
+ </div>
+ )}
</div>
</>
)}
diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsx
index ea51affa7..c5190c524 100644
--- a/src/components/SettingsPage.tsx
+++ b/src/components/SettingsPage.tsx
@@ -60,6 +60,7 @@ export default function SettingsPage({
openaiApiKey,
anthropicApiKey,
geminiApiKey,
+ groqApiKey,
dictationKey,
setUseLocalWhisper,
setWhisperModel,
@@ -75,6 +76,7 @@ export default function SettingsPage({
setOpenaiApiKey,
setAnthropicApiKey,
setGeminiApiKey,
+ setGroqApiKey,
setDictationKey,
updateTranscriptionSettings,
updateReasoningSettings,
@@ -255,15 +257,15 @@ export default function SettingsPage({
const normalizedReasoningBase = (cloudReasoningBaseUrl || '').trim();
setCloudReasoningBaseUrl(normalizedReasoningBase);
- // Update reasoning settings
- updateReasoningSettings({
- useReasoningModel,
+ // Update reasoning settings including the base URL
+ updateReasoningSettings({
+ useReasoningModel,
reasoningModel,
cloudReasoningBaseUrl: normalizedReasoningBase
});
-
- // Save API keys to backend based on provider
- if (localReasoningProvider === "openai" && openaiApiKey) {
+
+ // Save API keys to backend based on provider (including custom)
+ if ((localReasoningProvider === "openai" || localReasoningProvider === "custom") && openaiApiKey) {
await window.electronAPI?.saveOpenAIKey(openaiApiKey);
}
if (localReasoningProvider === "anthropic" && anthropicApiKey) {
@@ -272,16 +274,26 @@ export default function SettingsPage({
if (localReasoningProvider === "gemini" && geminiApiKey) {
await window.electronAPI?.saveGeminiKey(geminiApiKey);
}
-
- updateApiKeys({
- ...(localReasoningProvider === "openai" &&
- openaiApiKey.trim() && { openaiApiKey }),
- ...(localReasoningProvider === "anthropic" &&
- anthropicApiKey.trim() && { anthropicApiKey }),
- ...(localReasoningProvider === "gemini" &&
- geminiApiKey.trim() && { geminiApiKey }),
- });
-
+ if (localReasoningProvider === "groq" && groqApiKey) {
+ await window.electronAPI?.saveGroqKey(groqApiKey);
+ }
+
+ // Update API keys in state (for custom provider, save the API key used)
+ const keysToSave: Partial<{openaiApiKey: string; anthropicApiKey: string; geminiApiKey: string; groqApiKey: string}> = {};
+ if ((localReasoningProvider === "openai" || localReasoningProvider === "custom") && openaiApiKey.trim()) {
+ keysToSave.openaiApiKey = openaiApiKey;
+ }
+ if (localReasoningProvider === "anthropic" && anthropicApiKey.trim()) {
+ keysToSave.anthropicApiKey = anthropicApiKey;
+ }
+ if (localReasoningProvider === "gemini" && geminiApiKey.trim()) {
+ keysToSave.geminiApiKey = geminiApiKey;
+ }
+ if (localReasoningProvider === "groq" && groqApiKey.trim()) {
+ keysToSave.groqApiKey = groqApiKey;
+ }
+ updateApiKeys(keysToSave);
+
// Save the provider separately since it's computed from the model
localStorage.setItem("reasoningProvider", localReasoningProvider);
@@ -304,8 +316,12 @@ export default function SettingsPage({
useReasoningModel,
reasoningModel,
localReasoningProvider,
+ cloudReasoningBaseUrl,
openaiApiKey,
anthropicApiKey,
+ geminiApiKey,
+ groqApiKey,
+ setCloudReasoningBaseUrl,
updateReasoningSettings,
updateApiKeys,
showAlertDialog,
@@ -1041,6 +1057,8 @@ export default function SettingsPage({
setAnthropicApiKey={setAnthropicApiKey}
geminiApiKey={geminiApiKey}
setGeminiApiKey={setGeminiApiKey}
+ groqApiKey={groqApiKey}
+ setGroqApiKey={setGroqApiKey}
pasteFromClipboard={pasteFromClipboardWithFallback}
showAlertDialog={showAlertDialog}
/>
diff --git a/src/config/constants.ts b/src/config/constants.ts
index 68a00ad3d..90c79f2b1 100644
--- a/src/config/constants.ts
+++ b/src/config/constants.ts
@@ -71,6 +71,7 @@ export const API_ENDPOINTS = {
OPENAI_MODELS: buildApiUrl(DEFAULT_OPENAI_BASE, '/models'),
ANTHROPIC: 'https://api.anthropic.com/v1/messages',
GEMINI: 'https://generativelanguage.googleapis.com/v1beta',
+ GROQ_BASE: 'https://api.groq.com/openai/v1',
TRANSCRIPTION_BASE: DEFAULT_TRANSCRIPTION_BASE,
TRANSCRIPTION: buildApiUrl(DEFAULT_TRANSCRIPTION_BASE, '/audio/transcriptions'),
} as const;
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.js
index ff375b480..1d09c7284 100644
--- a/src/helpers/audioManager.js
+++ b/src/helpers/audioManager.js
@@ -536,7 +536,7 @@ class AudioManager {
const formData = new FormData();
formData.append("file", optimizedAudio, "audio.wav");
- formData.append("model", "whisper-1");
+ formData.append("model", this.getTranscriptionModel());
// Add language hint if set (improves processing speed)
const language = localStorage.getItem("preferredLanguage");
@@ -613,6 +613,33 @@ class AudioManager {
}
}
+ getTranscriptionModel() {
+ try {
+ // Check if a custom model is configured
+ const customModel = typeof localStorage !== "undefined"
+ ? localStorage.getItem("cloudTranscriptionModel") || ""
+ : "";
+
+ if (customModel.trim()) {
+ return customModel.trim();
+ }
+
+ // Auto-detect model based on endpoint
+ const endpoint = typeof localStorage !== "undefined"
+ ? localStorage.getItem("cloudTranscriptionBaseUrl") || ""
+ : "";
+
+ if (endpoint.includes("groq.com")) {
+ return "whisper-large-v3-turbo"; // Groq's fast model
+ }
+
+ // Default to OpenAI's model
+ return "whisper-1";
+ } catch (error) {
+ return "whisper-1";
+ }
+ }
+
getTranscriptionEndpoint() {
try {
const stored = typeof localStorage !== "undefined"
diff --git a/src/helpers/environment.js b/src/helpers/environment.js
index 5b6039a5a..d023fa2d2 100644
--- a/src/helpers/environment.js
+++ b/src/helpers/environment.js
@@ -91,6 +91,24 @@ class EnvironmentManager {
}
}
+ getGroqKey() {
+ const apiKey = process.env.GROQ_API_KEY;
+ return apiKey || "";
+ }
+
+ saveGroqKey(key) {
+ try {
+ // Update the environment variable in memory for immediate use
+ process.env.GROQ_API_KEY = key;
+ // Persist all keys to file
+ this.saveAllKeysToEnvFile();
+ return { success: true };
+ } catch (error) {
+ // Silent error - already throwing
+ throw error;
+ }
+ }
+
createProductionEnvFile(apiKey) {
try {
const envPath = path.join(app.getPath("userData"), ".env");
@@ -129,6 +147,9 @@ OPENAI_API_KEY=${apiKey}
if (process.env.GEMINI_API_KEY) {
envContent += `GEMINI_API_KEY=${process.env.GEMINI_API_KEY}\n`;
}
+ if (process.env.GROQ_API_KEY) {
+ envContent += `GROQ_API_KEY=${process.env.GROQ_API_KEY}\n`;
+ }
fs.writeFileSync(envPath, envContent, "utf8");
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index be2c0fbb7..1cc39efe3 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -392,6 +392,14 @@ class IPCHandlers {
return this.environmentManager.saveGeminiKey(key);
});
+ ipcMain.handle("get-groq-key", async (event) => {
+ return this.environmentManager.getGroqKey();
+ });
+
+ ipcMain.handle("save-groq-key", async (event, key) => {
+ return this.environmentManager.saveGroqKey(key);
+ });
+
ipcMain.handle("save-anthropic-key", async (event, key) => {
return this.environmentManager.saveAnthropicKey(key);
});
diff --git a/src/helpers/windowConfig.js b/src/helpers/windowConfig.js
index 2975eab9b..006d32f17 100644
--- a/src/helpers/windowConfig.js
+++ b/src/helpers/windowConfig.js
@@ -2,8 +2,8 @@ const path = require("path");
// Main dictation window configuration
const MAIN_WINDOW_CONFIG = {
- width: 240,
- height: 240,
+ width: 600,
+ height: 400,
webPreferences: {
preload: path.join(__dirname, "..", "..", "preload.js"),
nodeIntegration: false,
diff --git a/src/hooks/useSettings.ts b/src/hooks/useSettings.ts
index 374501f5c..078e7bffd 100644
--- a/src/hooks/useSettings.ts
+++ b/src/hooks/useSettings.ts
@@ -28,6 +28,7 @@ export interface ApiKeySettings {
openaiApiKey: string;
anthropicApiKey: string;
geminiApiKey: string;
+ groqApiKey: string;
}
export function useSettings() {
@@ -146,6 +147,15 @@ export function useSettings() {
}
);
+ const [groqApiKey, setGroqApiKey] = useLocalStorage(
+ "groqApiKey",
+ "",
+ {
+ serialize: String,
+ deserialize: String,
+ }
+ );
+
// Hotkey
const [dictationKey, setDictationKey] = useLocalStorage("dictationKey", "", {
serialize: String,
@@ -204,8 +214,10 @@ export function useSettings() {
setAnthropicApiKey(keys.anthropicApiKey);
if (keys.geminiApiKey !== undefined)
setGeminiApiKey(keys.geminiApiKey);
+ if (keys.groqApiKey !== undefined)
+ setGroqApiKey(keys.groqApiKey);
},
- [setOpenaiApiKey, setAnthropicApiKey, setGeminiApiKey]
+ [setOpenaiApiKey, setAnthropicApiKey, setGeminiApiKey, setGroqApiKey]
);
return {
@@ -223,6 +235,7 @@ export function useSettings() {
openaiApiKey,
anthropicApiKey,
geminiApiKey,
+ groqApiKey,
dictationKey,
setUseLocalWhisper,
setWhisperModel,
@@ -243,6 +256,7 @@ export function useSettings() {
openai: "gpt-4o-mini", // Start with cost-efficient multimodal model
anthropic: "claude-3.5-sonnet-20241022",
gemini: "gemini-2.5-flash",
+ groq: "qwen/qwen3-32b", // Groq's powerful reasoning model
local: "llama-3.2-3b",
};
setReasoningModel(
@@ -253,6 +267,7 @@ export function useSettings() {
setOpenaiApiKey,
setAnthropicApiKey,
setGeminiApiKey,
+ setGroqApiKey,
setDictationKey,
updateTranscriptionSettings,
updateReasoningSettings,
diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.ts
index ff75522b3..c156aeff8 100644
--- a/src/services/ReasoningService.ts
+++ b/src/services/ReasoningService.ts
@@ -135,21 +135,22 @@ class ReasoningService extends BaseReasoningService {
}
}
- private async getApiKey(provider: 'openai' | 'anthropic' | 'gemini'): Promise<string> {
+ private async getApiKey(provider: 'openai' | 'anthropic' | 'gemini' | 'groq'): Promise<string> {
let apiKey = this.apiKeyCache.get(provider);
-
+
debugLogger.logReasoning(`${provider.toUpperCase()}_KEY_RETRIEVAL`, {
provider,
fromCache: !!apiKey,
cacheSize: this.apiKeyCache.size || 0
});
-
+
if (!apiKey) {
try {
const keyGetters = {
openai: () => window.electronAPI.getOpenAIKey(),
anthropic: () => window.electronAPI.getAnthropicKey(),
gemini: () => window.electronAPI.getGeminiKey(),
+ groq: () => window.electronAPI.getGroqKey(),
};
apiKey = await keyGetters[provider]();
@@ -223,6 +224,9 @@ class ReasoningService extends BaseReasoningService {
case "gemini":
result = await this.processWithGemini(text, model, agentName, config);
break;
+ case "groq":
+ result = await this.processWithGroq(text, model, agentName, config);
+ break;
default:
throw new Error(`Unsupported reasoning provider: ${provider}`);
}
@@ -727,6 +731,158 @@ class ReasoningService extends BaseReasoningService {
}
}
+ private async processWithGroq(
+ text: string,
+ model: string,
+ agentName: string | null = null,
+ config: ReasoningConfig = {}
+ ): Promise<string> {
+ debugLogger.logReasoning("GROQ_START", {
+ model,
+ agentName,
+ hasApiKey: false
+ });
+
+ if (this.isProcessing) {
+ throw new Error("Already processing a request");
+ }
+
+ // Groq uses its own API key
+ const apiKey = await this.getApiKey('groq');
+
+ debugLogger.logReasoning("GROQ_API_KEY", {
+ hasApiKey: !!apiKey,
+ keyLength: apiKey?.length || 0
+ });
+
+ this.isProcessing = true;
+
+ try {
+ const systemPrompt = "You are a dictation assistant. Clean up text by fixing grammar and punctuation. Output ONLY the cleaned text without any explanations, options, or commentary.";
+ const userPrompt = this.getReasoningPrompt(text, agentName, config);
+
+ // Build messages array for Chat Completions format
+ const messages = [
+ { role: "system", content: systemPrompt },
+ { role: "user", content: userPrompt }
+ ];
+
+ const requestBody: any = {
+ model: model,
+ messages,
+ temperature: config.temperature || 0.6,
+ max_tokens: config.maxTokens || Math.max(
+ 4096,
+ this.calculateMaxTokens(
+ text.length,
+ TOKEN_LIMITS.MIN_TOKENS,
+ TOKEN_LIMITS.MAX_TOKENS,
+ TOKEN_LIMITS.TOKEN_MULTIPLIER
+ )
+ ),
+ };
+
+ const endpoint = buildApiUrl(API_ENDPOINTS.GROQ_BASE, '/chat/completions');
+
+ debugLogger.logReasoning("GROQ_REQUEST", {
+ endpoint,
+ model,
+ hasApiKey: !!apiKey,
+ requestBody: JSON.stringify(requestBody).substring(0, 200)
+ });
+
+ const response = await withRetry(
+ async () => {
+ const res = await fetch(endpoint, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${apiKey}`,
+ },
+ body: JSON.stringify(requestBody),
+ });
+
+ if (!res.ok) {
+ const errorText = await res.text();
+ let errorData: any = { error: res.statusText };
+
+ try {
+ errorData = JSON.parse(errorText);
+ } catch {
+ errorData = { error: errorText || res.statusText };
+ }
+
+ debugLogger.logReasoning("GROQ_API_ERROR_DETAIL", {
+ status: res.status,
+ statusText: res.statusText,
+ error: errorData,
+ errorMessage: errorData.error?.message || errorData.message || errorData.error,
+ fullResponse: errorText.substring(0, 500)
+ });
+
+ const errorMessage = errorData.error?.message || errorData.message || errorData.error || `Groq API error: ${res.status}`;
+ throw new Error(errorMessage);
+ }
+
+ const jsonResponse = await res.json();
+
+ debugLogger.logReasoning("GROQ_RAW_RESPONSE", {
+ hasResponse: !!jsonResponse,
+ responseKeys: jsonResponse ? Object.keys(jsonResponse) : [],
+ hasChoices: !!jsonResponse?.choices,
+ choicesLength: jsonResponse?.choices?.length || 0,
+ fullResponse: JSON.stringify(jsonResponse).substring(0, 500)
+ });
+
+ return jsonResponse;
+ },
+ createApiRetryStrategy("Groq")
+ );
+
+ // Extract text from Chat Completions format
+ if (!response.choices || !response.choices[0]) {
+ debugLogger.logReasoning("GROQ_RESPONSE_ERROR", {
+ model,
+ response: JSON.stringify(response).substring(0, 500),
+ hasChoices: !!response.choices,
+ choicesCount: response.choices?.length || 0
+ });
+ throw new Error("Invalid response structure from Groq API");
+ }
+
+ const choice = response.choices[0];
+ const responseText = choice.message?.content?.trim() || "";
+
+ if (!responseText) {
+ debugLogger.logReasoning("GROQ_EMPTY_RESPONSE", {
+ model,
+ finishReason: choice.finish_reason,
+ hasMessage: !!choice.message,
+ response: JSON.stringify(choice).substring(0, 500)
+ });
+ throw new Error("Groq returned empty response");
+ }
+
+ debugLogger.logReasoning("GROQ_RESPONSE", {
+ model,
+ responseLength: responseText.length,
+ tokensUsed: response.usage?.total_tokens || 0,
+ success: true
+ });
+
+ return responseText;
+ } catch (error) {
+ debugLogger.logReasoning("GROQ_ERROR", {
+ model,
+ error: (error as Error).message,
+ errorType: (error as Error).name
+ });
+ throw error;
+ } finally {
+ this.isProcessing = false;
+ }
+ }
+
async isAvailable(): Promise<boolean> {
try {
// Check if we have at least one configured API key or local model available
diff --git a/src/utils/languages.ts b/src/utils/languages.ts
index 86ba72500..d1623dc47 100644
--- a/src/utils/languages.ts
+++ b/src/utils/languages.ts
@@ -182,6 +182,41 @@ export const REASONING_PROVIDERS = {
},
],
},
+ groq: {
+ name: "Groq",
+ models: [
+ {
+ value: "qwen/qwen3-32b",
+ label: "Qwen3 32B",
+ description: "Powerful reasoning model (default)",
+ },
+ {
+ value: "llama-3.3-70b-versatile",
+ label: "LLaMA 3.3 70B",
+ description: "Meta's latest versatile model",
+ },
+ {
+ value: "llama3-70b-8192",
+ label: "LLaMA 3 70B",
+ description: "8K context, balanced performance",
+ },
+ {
+ value: "llama3-8b-8192",
+ label: "LLaMA 3 8B",
+ description: "Fast and efficient",
+ },
+ {
+ value: "mixtral-8x7b-32768",
+ label: "Mixtral 8x7B",
+ description: "32K context, mixture of experts",
+ },
+ {
+ value: "gemma2-9b-it",
+ label: "Gemma 2 9B",
+ description: "Google's efficient model",
+ },
+ ],
+ },
local: {
name: "Local AI",
models: [], // Will be populated dynamically
@@ -215,14 +250,17 @@ export const getReasoningModelLabel = (modelId: string): string => {
export const getModelProvider = (modelId: string): string => {
const allModels = getAllReasoningModels();
const model = allModels.find((m) => m.value === modelId);
-
+
// If model not found, try to infer from model name
if (!model) {
if (modelId.includes("claude")) return "anthropic";
- if (modelId.includes("gemini")) return "gemini";
+ if (modelId.includes("gemini") && !modelId.includes("gemma")) return "gemini";
if (modelId.includes("gpt") || modelId.includes("o3") || modelId.includes("o4") || modelId.includes("o1")) return "openai";
- if (modelId.includes("qwen") || modelId.includes("llama") || modelId.includes("mistral")) return "local";
+ // Groq-specific models (these run on Groq cloud, not local)
+ if (modelId.includes("qwen/") || modelId.includes("llama") || modelId.includes("mixtral") || modelId.includes("gemma")) return "groq";
+ // Other qwen, llama, mistral without slash are local
+ if (modelId.includes("qwen") || modelId.includes("mistral")) return "local";
}
-
+
return model?.provider || "openai";
};
\ No newline at end of file