diff --git a/admin/app/controllers/ollama_controller.ts b/admin/app/controllers/ollama_controller.ts index 3324eab..e58d249 100644 --- a/admin/app/controllers/ollama_controller.ts +++ b/admin/app/controllers/ollama_controller.ts @@ -189,6 +189,21 @@ export default class OllamaController { } } + async remoteStatus() { + const remoteUrl = await KVStore.getValue('ai.remoteOllamaUrl') + if (!remoteUrl) { + return { configured: false, connected: false } + } + try { + const testResponse = await fetch(`${remoteUrl.replace(/\/$/, '')}/v1/models`, { + signal: AbortSignal.timeout(3000), + }) + return { configured: true, connected: testResponse.ok } + } catch { + return { configured: true, connected: false } + } + } + async configureRemote({ request, response }: HttpContext) { const remoteUrl: string | null = request.input('remoteUrl', null) diff --git a/admin/inertia/components/chat/index.tsx b/admin/inertia/components/chat/index.tsx index db4ff6a..577579a 100644 --- a/admin/inertia/components/chat/index.tsx +++ b/admin/inertia/components/chat/index.tsx @@ -55,6 +55,13 @@ export default function Chat({ const { data: lastModelSetting } = useSystemSetting({ key: 'chat.lastModel', enabled }) const { data: remoteOllamaUrlSetting } = useSystemSetting({ key: 'ai.remoteOllamaUrl', enabled }) + const { data: remoteStatus } = useQuery({ + queryKey: ['remoteOllamaStatus'], + queryFn: () => api.getRemoteOllamaStatus(), + enabled: enabled && !!remoteOllamaUrlSetting?.value, + refetchInterval: 15000, + }) + const { data: installedModels = [], isLoading: isLoadingModels } = useQuery({ queryKey: ['installedModels'], queryFn: () => api.getInstalledModels(), @@ -365,8 +372,15 @@ export default function Chat({