From b0c92bf542e98309d47707fbab3270809dc9e794 Mon Sep 17 00:00:00 2001 From: monofuel Date: Fri, 12 Jan 2024 19:59:23 -0500 Subject: [PATCH] llama_leap client setup --- nimtemplate.nimble | 8 ++++---- src/llama_leap.nim | 23 +++++++++++++++++++++++ src/nimtemplate.nim | 3 --- src/nimtemplate/common.nim | 1 - tests/test.nim | 3 --- tests/test_llama_leap.nim | 16 ++++++++++++++++ 6 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 src/llama_leap.nim delete mode 100644 src/nimtemplate.nim delete mode 100644 src/nimtemplate/common.nim delete mode 100644 tests/test.nim create mode 100644 tests/test_llama_leap.nim diff --git a/nimtemplate.nimble b/nimtemplate.nimble index bd72628..36cb604 100644 --- a/nimtemplate.nimble +++ b/nimtemplate.nimble @@ -1,8 +1,8 @@ -version = "0.0.0" -author = "Your name" -description = "Description of your library" +version = "0.0.1" +author = "Andrew Brower" +description = "Ollama API for Nim" license = "MIT" srcDir = "src" -requires "nim >= 1.2.2" +requires "nim >= 2.0.0" diff --git a/src/llama_leap.nim b/src/llama_leap.nim new file mode 100644 index 0000000..04b7e5f --- /dev/null +++ b/src/llama_leap.nim @@ -0,0 +1,23 @@ +import curly + +## ollama API Interface +## https://github.com/jmorganca/ollama/blob/main/docs/api.md + +type + OllamaAPI* = ref object + curlPool: CurlPool + url: string + curlTimeout: float32 + +proc newOllamaAPI*( + url: string = "http://localhost:11434/api", + curlPoolSize: int = 4, + curlTimeout: float32 = 10000 +): OllamaAPI = + result = OllamaAPI() + result.curlPool = newCurlPool(curlPoolSize) + result.url = url + result.curlTimeout = curlTimeout + +proc close*(api: OllamaAPI) = + api.curlPool.close() diff --git a/src/nimtemplate.nim b/src/nimtemplate.nim deleted file mode 100644 index 5fcd576..0000000 --- a/src/nimtemplate.nim +++ /dev/null @@ -1,3 +0,0 @@ -## Public interface to you library. - -import nimtemplate/common diff --git a/src/nimtemplate/common.nim b/src/nimtemplate/common.nim deleted file mode 100644 index 869f4b5..0000000 --- a/src/nimtemplate/common.nim +++ /dev/null @@ -1 +0,0 @@ -## Add private variables or functions here that you don't want to export. diff --git a/tests/test.nim b/tests/test.nim deleted file mode 100644 index 41fa755..0000000 --- a/tests/test.nim +++ /dev/null @@ -1,3 +0,0 @@ -## Put your tests here. - -import nimtemplate diff --git a/tests/test_llama_leap.nim b/tests/test_llama_leap.nim new file mode 100644 index 0000000..b97ca8d --- /dev/null +++ b/tests/test_llama_leap.nim @@ -0,0 +1,16 @@ +## llama_leap API tests +## Ensure that ollama is running! + +import llama_leap, unittest + + +suite "llama_leap": + var ollama: OllamaAPI + + setup: + ollama = newOllamaApi() + teardown: + ollama.close() + + test "TODO": + echo "TODO"