An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
chore: Enable Groq integration with API keys and models
Yoshiki Miura2c10a924b453
diff --git a/.env.local.example b/.env.local.exampleindex ef3c76fe..d48519c5 100644--- a/.env.local.example+++ b/.env.local.example@@ -57,6 +57,10 @@ SEARXNG_SAFESEARCH=0 # Safe search setting: 0 (off), 1 (moderate), 2 (strict)# If you want to use Anthropic instead of OpenAI, enable the following settings.# ANTHROPIC_API_KEY=[YOUR_ANTHROPIC_API_KEY]+# If you want to use Groq, enable the following variables. only available for tool use compatible models.+# GROQ_API_KEY=[YOUR_GROQ_API_KEY]+# GROQ_API_MODEL=[YOUR_GROQ_API_MODEL] # e.g. llama3-groq-8b-8192-tool-use-preview+# If you want to use Ollama, enable the following variables.# OLLAMA_MODEL=[YOUR_OLLAMA_MODEL] # The main model to use. Currently compatible: qwen2.5# OLLAMA_BASE_URL=[YOUR_OLLAMA_URL] # The base URL to use. e.g. http://localhost:11434diff --git a/lib/utils/index.ts b/lib/utils/index.tsindex fcd4a7ae..64a9ef46 100644--- a/lib/utils/index.ts+++ b/lib/utils/index.ts@@ -23,6 +23,8 @@ export function getModel(useSubModel = false) {let azureDeploymentName = process.env.AZURE_DEPLOYMENT_NAME || 'gpt-4o'const googleApiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEYconst anthropicApiKey = process.env.ANTHROPIC_API_KEY+ const groqApiKey = process.env.GROQ_API_KEY+ const groqApiModel = process.env.GROQ_API_MODELif (!(ollamaBaseUrl && ollamaModel) &&@@ -63,6 +65,15 @@ export function getModel(useSubModel = false) {return azure.chat(azureDeploymentName)}+ if (groqApiKey && groqApiModel) {+ const groq = createOpenAI({+ apiKey: groqApiKey,+ baseURL: 'https://api.groq.com/openai/v1'+ })++ return groq.chat(groqApiModel)+ }+// Fallback to OpenAI insteadconst openai = createOpenAI({baseURL: openaiApiBase, // optional base URL for proxies etc.