From f153a14dafcf3a2a05369b709e70a583ca6b974a Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 4 Nov 2024 21:29:26 +0800 Subject: [PATCH] add common identity provider /.well-known/serviceinfo, updated docs --- kcpp_docs.embd | 37 +++++++++++++++++++++++++++++++++++-- koboldcpp.py | 3 +++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/kcpp_docs.embd b/kcpp_docs.embd index 827707241..647d2fad7 100644 --- a/kcpp_docs.embd +++ b/kcpp_docs.embd @@ -191,7 +191,10 @@ }, "images": { "description": "KoboldCpp ONLY. If set, takes an array of base64 encoded strings, each one representing an image to be processed.", - "type": "array" + "type": "array", + "items": { + "type": "string" + } }, "trim_stop": { "default": false, @@ -1168,6 +1171,29 @@ ] } }, + "/.well-known/serviceinfo": { + "get": { + "responses": { + "200": { + "content": { + "application/json": { + "example": {"version":"0.2","software":{"name":"KoboldCpp","version":1.77,"repository":"https://github.com/LostRuins/koboldcpp","homepage":"https://github.com/LostRuins/koboldcpp","logo":"https://raw.githubusercontent.com/LostRuins/koboldcpp/refs/heads/concedo/niko.ico"},"api":{"koboldai":{"name":"KoboldAI API","rel_url":"/api","documentation":"https://lite.koboldai.net/koboldcpp_api","version":1.77},"openai":{"name":"OpenAI API","rel_url ":"/v1","documentation":"https://openai.com/documentation/api","version":1.77}}}, + "schema": { + "properties": {}, + "type": "object" + } + } + }, + "description": "Successful request" + } + }, + "description": "Retrieve the common API identity provider", + "summary": "Retrieve the common API identity provider", + "tags": [ + "serviceinfo" + ] + } + }, "/sdapi/v1/sd-models": { "get": { "description": "Gets a list of image generation models. For koboldcpp, only one model will be returned. If no model is loaded, the list is empty.", @@ -1364,7 +1390,10 @@ "type": "number" }, "init_images": { - "type": "array" + "type": "array", + "items": { + "type": "string" + } }, }, "type": "object" @@ -1517,6 +1546,10 @@ "description": "Extended API unique to KoboldCpp", "name": "api/extra" }, + { + "description": "Common identity API for LLM services", + "name": "serviceinfo" + }, { "description": "Image Generation API (A1111 compatible)", "name": "sdapi/v1" diff --git a/koboldcpp.py b/koboldcpp.py index fd0b90eab..ac21793cf 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -1898,6 +1898,9 @@ Enter Prompt:
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(('/.well-known/serviceinfo')): + response_body = (json.dumps({"version":"0.2","software":{"name":"KoboldCpp","version":KcppVersion,"repository":"https://github.com/LostRuins/koboldcpp","homepage":"https://github.com/LostRuins/koboldcpp","logo":"https://raw.githubusercontent.com/LostRuins/koboldcpp/refs/heads/concedo/niko.ico"},"api":{"koboldai":{"name":"KoboldAI API","rel_url":"/api","documentation":"https://lite.koboldai.net/koboldcpp_api","version":KcppVersion},"openai":{"name":"OpenAI API","rel_url ":"/v1","documentation":"https://openai.com/documentation/api","version":KcppVersion}}}).encode()) + elif self.path=="/api" or self.path=="/docs" or self.path.startswith(('/api/?json=','/api?json=','/docs/?json=','/docs?json=')): content_type = 'text/html' if embedded_kcpp_docs is None: