An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
Refactor environment variables and provider configuration
Yoshiki Miura144e3126fe61
diff --git a/.env.local.example b/.env.local.exampleindex b04a969f..9bc26308 100644--- a/.env.local.example+++ b/.env.local.example@@ -47,6 +47,9 @@ SEARXNG_SAFESEARCH=0 # Safe search setting: 0 (off), 1 (moderate), 2 (strict)# Groq API key retrieved here: https://console.groq.com/keys# GROQ_API_KEY=[YOUR_GROQ_API_KEY]+# Ollama Base URL+# OLLAMA_BASE_URL=http://localhost:11434+# Azure OpenAI API key retrieved here: https://oai.azure.com/resource/deployments/# AZURE_API_KEY=# The resource name is used in the assembled URL: https://{resourceName}.openai.azure.com/openai/deployments/{modelId}{path}.diff --git a/app/actions.tsx b/app/actions.tsxindex b706c835..d110e773 100644--- a/app/actions.tsx+++ b/app/actions.tsx@@ -78,7 +78,7 @@ async function submit(// Check if provider is enabledif (!isProviderEnabled(providerId)) {throw new Error(- `Provider ${providerId} is not available (API key not configured)`+ `Provider ${providerId} is not available (API key not configured or base URL not set)`)}diff --git a/lib/utils/registry.ts b/lib/utils/registry.tsindex f2f6329c..b41696b5 100644--- a/lib/utils/registry.ts+++ b/lib/utils/registry.ts@@ -3,7 +3,7 @@ import { openai, createOpenAI } from '@ai-sdk/openai'import { anthropic } from '@ai-sdk/anthropic'import { google } from '@ai-sdk/google'import { createAzure } from '@ai-sdk/azure'-import { ollama } from 'ollama-ai-provider'+import { createOllama } from 'ollama-ai-provider'export const registry = createProviderRegistry({openai,@@ -13,7 +13,9 @@ export const registry = createProviderRegistry({apiKey: process.env.GROQ_API_KEY,baseURL: 'https://api.groq.com/openai/v1'}),- ollama,+ ollama: createOllama({+ baseURL: `${process.env.OLLAMA_BASE_URL}/api`+ }),azure: createAzure({apiKey: process.env.AZURE_API_KEY,resourceName: process.env.AZURE_RESOURCE_NAME@@ -35,7 +37,7 @@ export function isProviderEnabled(providerId: string): boolean {case 'groq':return !!process.env.GROQ_API_KEYcase 'ollama':- return true+ return !!process.env.OLLAMA_BASE_URLcase 'azure':return !!process.env.AZURE_API_KEY && !!process.env.AZURE_RESOURCE_NAMEdefault: