Skip to content

Commit

Permalink
feat(llm): set ollama host from env
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Dvorak <toomas2d@gmail.com>
  • Loading branch information
Tomas2D committed Oct 27, 2024
1 parent a815053 commit 4712e87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/adapters/ollama/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -130,7 +131,7 @@ export class OllamaChatLLM extends ChatLLM<OllamaChatLLMOutput> {
},
) {
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,
Expand Down
3 changes: 2 additions & 1 deletion src/adapters/ollama/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -119,7 +120,7 @@ export class OllamaLLM extends LLM<OllamaLLMOutput> {

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 ?? {};
}

Expand Down

0 comments on commit 4712e87

Please sign in to comment.