Skip to content

Commit

Permalink
get version
Browse files Browse the repository at this point in the history
  • Loading branch information
monofuel committed Jan 13, 2024
1 parent 50722e8 commit c7815f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/llama_leap.nim
Original file line number Diff line number Diff line change
Expand Up @@ -350,3 +350,11 @@ proc generateEmbeddings*(
# TODO: POST /api/copy
# TODO: DELETE /api/delete
# TODO: POST /api/push

proc getVersion*(api: OllamaAPI): string =
let url = api.baseUrl / "version"
let resp = api.curlPool.get(url, timeout = api.curlTimeout)
if resp.code != 200:
raise newException(CatchableError, &"ollama version failed: {resp.code} {resp.body}")
let json = fromJson(resp.body)
result = json["version"].getStr
4 changes: 4 additions & 0 deletions tests/test_llama_leap.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ suite "llama_leap":
teardown:
ollama.close()

suite "version":
test "version":
echo "> " & ollama.getVersion()

suite "pull":
test "pull model":
ollama.pullModel(TestModel)
Expand Down

0 comments on commit c7815f7

Please sign in to comment.