Skip to content

Commit

Permalink
ollama api env var
Browse files Browse the repository at this point in the history
  • Loading branch information
monofuel committed Apr 20, 2024
1 parent 17cc838 commit 9d614d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion monoprompt.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.0.11"
version = "1.0.12"
author = "Andrew Brower"
description = "monoprompt project"
license = "MIT"
Expand Down
9 changes: 8 additions & 1 deletion src/ai.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9d614d7

Please sign in to comment.