From 9d614d7807624cfbae23911e8a5d2ec0663d2b60 Mon Sep 17 00:00:00 2001 From: monofuel Date: Fri, 19 Apr 2024 21:12:33 -0400 Subject: [PATCH] ollama api env var --- README.md | 1 + monoprompt.nimble | 2 +- src/ai.nim | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6a0135b..c9cb0c2 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,7 @@ At the end of the file, include a `when isMainModule:` block with tests for how ## Environment - set `OPENAI_API_KEY` to your OpenAI API key if you want to use the OpenAI API. +- set `OLLAMA_BASE_URL` if you want to use the Ollama API on a different server. defaults to `http://localhost:11434/api`. ## Fine-Tuning diff --git a/monoprompt.nimble b/monoprompt.nimble index 46493c8..5b1cd42 100644 --- a/monoprompt.nimble +++ b/monoprompt.nimble @@ -1,4 +1,4 @@ -version = "1.0.11" +version = "1.0.12" author = "Andrew Brower" description = "monoprompt project" license = "MIT" diff --git a/src/ai.nim b/src/ai.nim index 8ceb78c..0630d1f 100644 --- a/src/ai.nim +++ b/src/ai.nim @@ -9,7 +9,14 @@ proc setup*() = if openAIKey != "": echo &"DEBUG: OpenAI API key found, initializing OpenAI API" openai = newOpenAIAPI() - ollama = newOllamaAPI() + + let ollamaBaseUrl = getEnv("OLLAMA_BASE_URL", "") + if ollamaBaseUrl != "": + echo &"DEBUG: Ollama base URL found, initializing Ollama API with URL {ollamaBaseUrl}" + ollama = newOllamaAPI(ollamaBaseUrl) + else: + # library defaults to "http://localhost:11434/api" + ollama = newOllamaAPI() proc close*() = if openai != nil: