From e2afe1a522e0fa4a35a5f168f350a6a1b590592a Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Wed, 14 Jan 2026 19:15:48 +0100 Subject: [PATCH] changes --- app/actions/chat.ts | 3 ++- app/actions/ollama.ts | 2 +- lib/ollama.ts | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 lib/ollama.ts diff --git a/app/actions/chat.ts b/app/actions/chat.ts index b650635..f95cb5b 100644 --- a/app/actions/chat.ts +++ b/app/actions/chat.ts @@ -1,6 +1,7 @@ 'use server'; -import ollama, { Tool } from 'ollama'; +import { Tool } from 'ollama'; +import ollama from '@/lib/ollama'; export interface ChatMessage { role: 'user' | 'assistant' | 'system' | 'tool'; diff --git a/app/actions/ollama.ts b/app/actions/ollama.ts index 997c569..a23f866 100644 --- a/app/actions/ollama.ts +++ b/app/actions/ollama.ts @@ -1,6 +1,6 @@ 'use server'; -import ollama from 'ollama'; +import ollama from '@/lib/ollama'; export interface OllamaModel { name: string; diff --git a/lib/ollama.ts b/lib/ollama.ts new file mode 100644 index 0000000..9bd9563 --- /dev/null +++ b/lib/ollama.ts @@ -0,0 +1,12 @@ +import { Ollama } from 'ollama'; + +// Initialize Ollama with the host from environment variables +// defaulting to localhost if not specified. +// This ensures that OLLAMA_HOST is respected. +const host = process.env.OLLAMA_HOST || 'http://127.0.0.1:11434'; + +console.log(`Initializing Ollama client with host: ${host}`); + +const ollama = new Ollama({ host }); + +export default ollama;