-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handling OLLAMA_HOST * docs: ✏️ add note on GenAIScript using Ollama API * added ollama docker command * updated docs
- Loading branch information
Showing
7 changed files
with
125 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { describe, test } from "node:test" | ||
import assert from "node:assert/strict" | ||
import { parseHostVariable } from "./ollama" | ||
import { OLLAMA_API_BASE, OLLAMA_DEFAUT_PORT } from "./constants" | ||
|
||
describe("parseHostVariable", () => { | ||
test("parses OLLAMA_HOST environment variable correctly", () => { | ||
const env = { OLLAMA_HOST: "http://localhost:3000" } | ||
const result = parseHostVariable(env) | ||
assert.strictEqual(result, "http://localhost:3000/") | ||
}) | ||
|
||
test("parses OLLAMA_API_BASE environment variable correctly", () => { | ||
const env = { OLLAMA_API_BASE: "http://api.ollama.com" } | ||
const result = parseHostVariable(env) | ||
assert.strictEqual(result, "http://api.ollama.com/") | ||
}) | ||
|
||
test("falls back to OLLAMA_API_BASE constant if no environment variable is set", () => { | ||
const env = {} | ||
const result = parseHostVariable(env) | ||
assert.strictEqual(result, OLLAMA_API_BASE) | ||
}) | ||
|
||
test("parses IP address with port correctly", () => { | ||
const env = { OLLAMA_HOST: "192.168.1.1:8080" } | ||
const result = parseHostVariable(env) | ||
assert.strictEqual(result, "http://192.168.1.1:8080") | ||
}) | ||
|
||
test("parses IP address without port correctly", () => { | ||
const env = { OLLAMA_HOST: "192.168.1.1" } | ||
const result = parseHostVariable(env) | ||
assert.strictEqual(result, `http://192.168.1.1:${OLLAMA_DEFAUT_PORT}`) | ||
}) | ||
|
||
test("parses 0.0.0.0 with port correctly", () => { | ||
const env = { OLLAMA_HOST: "0.0.0.0:4000" } | ||
const result = parseHostVariable(env) | ||
assert.strictEqual(result, "http://0.0.0.0:4000") | ||
}) | ||
|
||
test("parses localhost with port correctly", () => { | ||
const env = { OLLAMA_HOST: "localhost:4000" } | ||
const result = parseHostVariable(env) | ||
assert.strictEqual(result, "http://localhost:4000") | ||
}) | ||
|
||
test("parses 0.0.0.0 without port correctly", () => { | ||
const env = { OLLAMA_HOST: "0.0.0.0" } | ||
const result = parseHostVariable(env) | ||
assert.strictEqual(result, `http://0.0.0.0:${OLLAMA_DEFAUT_PORT}`) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters