From 6c9ccc0f95dbc9dd4b1e0f07e83bae0ea2eaf9a9 Mon Sep 17 00:00:00 2001 From: Arjun <6592213+arkml@users.noreply.github.com> Date: Thu, 12 Feb 2026 11:40:55 +0530 Subject: [PATCH] fixed ollama --- apps/x/packages/core/src/models/models.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/x/packages/core/src/models/models.ts b/apps/x/packages/core/src/models/models.ts index 482931df..ab332fb6 100644 --- a/apps/x/packages/core/src/models/models.ts +++ b/apps/x/packages/core/src/models/models.ts @@ -39,11 +39,17 @@ export function createProvider(config: z.infer): ProviderV2 { baseURL, headers, }); - case "ollama": + case "ollama": { + // ollama-ai-provider-v2 expects baseURL to include /api + let ollamaURL = baseURL; + if (ollamaURL && !ollamaURL.replace(/\/+$/, '').endsWith('/api')) { + ollamaURL = ollamaURL.replace(/\/+$/, '') + '/api'; + } return createOllama({ - baseURL, + baseURL: ollamaURL, headers, }); + } case "openai-compatible": return createOpenAICompatible({ name: "openai-compatible", @@ -65,10 +71,12 @@ export function createProvider(config: z.infer): ProviderV2 { export async function testModelConnection( providerConfig: z.infer, model: string, - timeoutMs: number = 8000, + timeoutMs?: number, ): Promise<{ success: boolean; error?: string }> { + const isLocal = providerConfig.flavor === "ollama" || providerConfig.flavor === "openai-compatible"; + const effectiveTimeout = timeoutMs ?? (isLocal ? 60000 : 8000); const controller = new AbortController(); - const timeout = setTimeout(() => controller.abort(), timeoutMs); + const timeout = setTimeout(() => controller.abort(), effectiveTimeout); try { const provider = createProvider(providerConfig); const languageModel = provider.languageModel(model);