Skip to content

An AI-powered search engine with a generative UI

feat: Support openai compatible model

Yoshiki Miura50f1a2887a23
diff --git a/.env.local.example b/.env.local.example
index 9bc26308..7cc35a23 100644
--- a/.env.local.example
+++ b/.env.local.example
@@ -47,7 +47,7 @@ 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
+# If you want to use Ollama, set the base URL here.
# OLLAMA_BASE_URL=http://localhost:11434
# Azure OpenAI API key retrieved here: https://oai.azure.com/resource/deployments/
@@ -55,6 +55,10 @@ SEARXNG_SAFESEARCH=0 # Safe search setting: 0 (off), 1 (moderate), 2 (strict)
# The resource name is used in the assembled URL: https://{resourceName}.openai.azure.com/openai/deployments/{modelId}{path}.
# AZURE_RESOURCE_NAME=
+# OpenAI Compatible Model
+# NEXT_PUBLIC_OPENAI_COMPATIBLE_MODEL=[YOUR_OPENAI_COMPATIBLE_MODEL]
+# OPENAI_COMPATIBLE_API_KEY=[YOUR_OPENAI_COMPATIBLE_API_KEY]
+# OPENAI_COMPATIBLE_API_BASE_URL=[YOUR_OPENAI_COMPATIBLE_API_BASE_URL]
# enable the share feature
# If you enable this feature, separate account management implementation is required.
diff --git a/components/chat-panel.tsx b/components/chat-panel.tsx
index 154b3594..830e2182 100644
--- a/components/chat-panel.tsx
+++ b/components/chat-panel.tsx
@@ -89,7 +89,7 @@ export function ChatPanel({ messages, query, onModelChange }: ChatPanelProps) {
await handleQuerySubmit(input, formData)
} catch (error) {
console.error('Error submitting form:', error)
- toast.error('Error: ' + error)
+ toast.error(`${error}`)
handleClear()
}
diff --git a/lib/types/models.ts b/lib/types/models.ts
index d1a7b9dd..e0fabf1f 100644
--- a/lib/types/models.ts
+++ b/lib/types/models.ts
@@ -47,5 +47,11 @@ export const models: Model[] = [
name: 'GPT-4o',
provider: 'Azure',
providerId: 'azure'
+ },
+ {
+ id: process.env.NEXT_PUBLIC_OPENAI_COMPATIBLE_MODEL || 'undefined',
+ name: process.env.NEXT_PUBLIC_OPENAI_COMPATIBLE_MODEL || 'Undefined',
+ provider: 'OpenAI Compatible',
+ providerId: 'openai-compatible'
}
]
diff --git a/lib/utils/registry.ts b/lib/utils/registry.ts
index b41696b5..850e9a04 100644
--- a/lib/utils/registry.ts
+++ b/lib/utils/registry.ts
@@ -19,6 +19,10 @@ export const registry = createProviderRegistry({
azure: createAzure({
apiKey: process.env.AZURE_API_KEY,
resourceName: process.env.AZURE_RESOURCE_NAME
+ }),
+ 'openai-compatible': createOpenAI({
+ apiKey: process.env.OPENAI_COMPATIBLE_API_KEY,
+ baseURL: process.env.OPENAI_COMPATIBLE_API_BASE_URL
})
})
@@ -40,6 +44,12 @@ export function isProviderEnabled(providerId: string): boolean {
return !!process.env.OLLAMA_BASE_URL
case 'azure':
return !!process.env.AZURE_API_KEY && !!process.env.AZURE_RESOURCE_NAME
+ case 'openai-compatible':
+ return (
+ !!process.env.OPENAI_COMPATIBLE_API_KEY &&
+ !!process.env.OPENAI_COMPATIBLE_API_BASE_URL &&
+ !!process.env.NEXT_PUBLIC_OPENAI_COMPATIBLE_MODEL
+ )
default:
return false
}
diff --git a/public/providers/logos/openai-compatible.svg b/public/providers/logos/openai-compatible.svg
new file mode 100644
index 00000000..141df123
--- /dev/null
+++ b/public/providers/logos/openai-compatible.svg
@@ -0,0 +1,3 @@
+<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
+<circle cx="50" cy="50" r="32" fill="black"/>
+</svg>