From 4712e877c46be98208a5721f25c55308d2f91706 Mon Sep 17 00:00:00 2001 From: Tomas Dvorak Date: Sat, 26 Oct 2024 21:48:54 -0700 Subject: [PATCH] feat(llm): set ollama host from env Signed-off-by: Tomas Dvorak --- src/adapters/ollama/chat.ts | 3 ++- src/adapters/ollama/llm.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/adapters/ollama/chat.ts b/src/adapters/ollama/chat.ts index eed77d1d..8649404f 100644 --- a/src/adapters/ollama/chat.ts +++ b/src/adapters/ollama/chat.ts @@ -35,6 +35,7 @@ import { Cache } from "@/cache/decoratorCache.js"; import { customMerge } from "@/internals/helpers/object.js"; import { safeSum } from "@/internals/helpers/number.js"; import { extractModelMeta, registerClient } from "@/adapters/ollama/shared.js"; +import { getEnv } from "@/internals/env.js"; export class OllamaChatLLMOutput extends ChatLLMOutput { public readonly results: ChatResponse[]; @@ -130,7 +131,7 @@ export class OllamaChatLLM extends ChatLLM { }, ) { super(modelId, executionOptions, cache); - this.client = client ?? new Client({ fetch }); + this.client = client ?? new Client({ fetch, host: getEnv("OLLAMA_HOST") }); this.parameters = parameters ?? { temperature: 0, repeat_penalty: 1.0, diff --git a/src/adapters/ollama/llm.ts b/src/adapters/ollama/llm.ts index cfc97a61..926eabdd 100644 --- a/src/adapters/ollama/llm.ts +++ b/src/adapters/ollama/llm.ts @@ -36,6 +36,7 @@ import { shallowCopy } from "@/serializer/utils.js"; import { signalRace } from "@/internals/helpers/promise.js"; import { customMerge } from "@/internals/helpers/object.js"; import { extractModelMeta, registerClient } from "@/adapters/ollama/shared.js"; +import { getEnv } from "@/internals/env.js"; interface Input { modelId: string; @@ -119,7 +120,7 @@ export class OllamaLLM extends LLM { constructor({ client, modelId, parameters, executionOptions = {}, cache }: Input) { super(modelId, executionOptions, cache); - this.client = client ?? new Client(); + this.client = client ?? new Client({ host: getEnv("OLLAMA_HOST") }); this.parameters = parameters ?? {}; }