From 06d2bc3404cae786df6ce7490e2cba8b9460b3db Mon Sep 17 00:00:00 2001
From: Concedo <39025047+LostRuins@users.noreply.github.com>
Date: Wed, 4 Jun 2025 19:22:29 +0800
Subject: [PATCH] ollama compat fixes
---
koboldcpp.py | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/koboldcpp.py b/koboldcpp.py
index e8ff4dc7a..0e9d5b3f4 100644
--- a/koboldcpp.py
+++ b/koboldcpp.py
@@ -3011,15 +3011,18 @@ Change Mode
elif self.path.endswith('/sdapi/v1/upscalers'):
response_body = (json.dumps([]).encode())
- elif self.path.endswith(('/speakers_list')): #xtts compatible
+ elif self.path.endswith('/speakers_list'): #xtts compatible
response_body = (json.dumps(["kobo","cheery","sleepy","shouty","chatty"]).encode()) #some random voices for them to enjoy
- elif self.path.endswith(('/speakers')): #xtts compatible
+ elif self.path.endswith('/speakers'): #xtts compatible
response_body = (json.dumps([{"name":"kobo","voice_id":"kobo","preview_url":""},{"name":"cheery","voice_id":"cheery","preview_url":""},{"name":"sleepy","voice_id":"sleepy","preview_url":""},{"name":"shouty","voice_id":"shouty","preview_url":""},{"name":"chatty","voice_id":"chatty","preview_url":""}]).encode()) #some random voices for them to enjoy
- elif self.path.endswith(('/get_tts_settings')): #xtts compatible
+ elif self.path.endswith('/get_tts_settings'): #xtts compatible
response_body = (json.dumps({"temperature":0.75,"speed":1,"length_penalty":1,"repetition_penalty":1,"top_p":1,"top_k":4,"enable_text_splitting":True,"stream_chunk_size":100}).encode()) #some random voices for them to enjoy
- elif self.path.endswith(('/api/tags')): #ollama compatible
- response_body = (json.dumps({"models":[{"name":"koboldcpp","model":friendlymodelname,"modified_at":"2024-07-19T15:26:55.6122841+08:00","size":394998579,"digest":"b5dc5e784f2a3ee1582373093acf69a2f4e2ac1710b253a001712b86a61f88bb","details":{"parent_model":"","format":"gguf","family":"koboldcpp","families":["koboldcpp"],"parameter_size":"128M","quantization_level":"Q4_0"}}]}).encode())
+ elif self.path.endswith('/api/tags') or self.path.endswith('/api/ps'): #ollama compatible
+ response_body = (json.dumps({"models":[{"name":"koboldcpp","model":friendlymodelname,"modified_at":"2024-07-19T15:26:55.6122841+08:00","expires_at": "2055-06-04T19:06:25.5433636+08:00","size":394998579,"size_vram":394998579,"digest":"b5dc5e784f2a3ee1582373093acf69a2f4e2ac1710b253a001712b86a61f88bb","details":{"parent_model":"","format":"gguf","family":"koboldcpp","families":["koboldcpp"],"parameter_size":"128M","quantization_level":"Q4_0"}}]}).encode())
+ elif self.path.endswith('/api/version'): #ollama compatible, NOT the kcpp version
+ response_body = (json.dumps({"version":"0.7.0"}).encode())
+
#comfyui compatible
elif self.path=='/system_stats':
@@ -3570,9 +3573,9 @@ Change Mode
}}).encode())
return
api_format = 5
- elif self.path.endswith('/api/generate'):
+ elif self.path.endswith('/api/generate'): #ollama
api_format = 6
- elif self.path.endswith('/api/chat'):
+ elif self.path.endswith('/api/chat'): #ollama
api_format = 7
elif self.path=="/prompt" or self.path.endswith('/sdapi/v1/txt2img') or self.path.endswith('/sdapi/v1/img2img'):
is_imggen = True