This commit is contained in:
@@ -1 +1 @@
|
||||
0.1.0
|
||||
0.1.1
|
||||
|
||||
@@ -10,6 +10,11 @@ import requests
|
||||
|
||||
OLLAMA_URL = os.environ.get("OLLAMA_URL", "http://127.0.0.1:11434/api/chat")
|
||||
MODEL = os.environ.get("OLLAMA_MODEL", "qwen2.5:3b")
|
||||
# Ollama restarts its runner when a request's context size or thread count
|
||||
# differs from the loaded one; set these to match other clients of a shared
|
||||
# Ollama. OLLAMA_NUM_THREAD unset = Ollama's default.
|
||||
NUM_CTX = int(os.environ.get("OLLAMA_NUM_CTX", "3072"))
|
||||
NUM_THREAD = os.environ.get("OLLAMA_NUM_THREAD")
|
||||
|
||||
SCHEMA = {
|
||||
"type": "object",
|
||||
@@ -57,6 +62,9 @@ Respond with ONLY the JSON object, no other text.
|
||||
|
||||
|
||||
def structure(ocr_text: str) -> dict:
|
||||
options = {"temperature": 0, "num_ctx": NUM_CTX}
|
||||
if NUM_THREAD:
|
||||
options["num_thread"] = int(NUM_THREAD)
|
||||
payload = {
|
||||
"model": MODEL,
|
||||
"messages": [
|
||||
@@ -64,7 +72,7 @@ def structure(ocr_text: str) -> dict:
|
||||
],
|
||||
"format": SCHEMA,
|
||||
"stream": False,
|
||||
"options": {"temperature": 0, "num_ctx": 3072},
|
||||
"options": options,
|
||||
}
|
||||
|
||||
start = time.time()
|
||||
|
||||
Reference in New Issue
Block a user