From ff1c0c48985bbbfd3640676d2b5914ad57dda9a9 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Tue, 21 Mar 2023 20:41:19 +0800 Subject: [PATCH] added embedded copy of kobold lite --- klite.embd | 27 +++++++++++++++++++++++++++ llama_for_kobold.py | 24 ++++++++++++------------ 2 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 klite.embd diff --git a/klite.embd b/klite.embd new file mode 100644 index 000000000..395fde6ec --- /dev/null +++ b/klite.embd @@ -0,0 +1,27 @@ + + + + + +KoboldAI Lite + + + + + + + + +

Connecting...

You're using Kobold Lite Embedded.
\ No newline at end of file diff --git a/llama_for_kobold.py b/llama_for_kobold.py index 982665852..2e8369eb4 100644 --- a/llama_for_kobold.py +++ b/llama_for_kobold.py @@ -80,34 +80,31 @@ modelbusy = False port = 5001 last_context = "" -class ServerRequestHandler(http.server.BaseHTTPRequestHandler): +class ServerRequestHandler(http.server.SimpleHTTPRequestHandler): sys_version = "" server_version = "ConcedoLlamaForKoboldServer" def do_GET(self): - if not self.path.endswith('/'): - # redirect browser - self.send_response(301) - self.send_header("Location", self.path + "/") - self.end_headers() - return - - if self.path.endswith('/api/v1/model/') or self.path.endswith('/api/latest/model/'): + if self.path=="/": + self.path = "/klite.embd" + return http.server.SimpleHTTPRequestHandler.do_GET(self) + + if self.path.endswith('/api/v1/model/') or self.path.endswith('/api/latest/model/') or self.path.endswith('/api/v1/model') or self.path.endswith('/api/latest/model'): self.send_response(200) self.end_headers() global friendlymodelname self.wfile.write(json.dumps({"result": friendlymodelname }).encode()) return - if self.path.endswith('/api/v1/config/max_length/') or self.path.endswith('/api/latest/config/max_length/'): + if self.path.endswith('/api/v1/config/max_length/') or self.path.endswith('/api/latest/config/max_length/') or self.path.endswith('/api/v1/config/max_length') or self.path.endswith('/api/latest/config/max_length'): self.send_response(200) self.end_headers() global maxlen self.wfile.write(json.dumps({"value":maxlen}).encode()) return - if self.path.endswith('/api/v1/config/max_context_length/') or self.path.endswith('/api/latest/config/max_context_length/'): + if self.path.endswith('/api/v1/config/max_context_length/') or self.path.endswith('/api/latest/config/max_context_length/') or self.path.endswith('/api/v1/config/max_context_length') or self.path.endswith('/api/latest/config/max_context_length'): self.send_response(200) self.end_headers() global maxctx @@ -187,7 +184,10 @@ class ServerRequestHandler(http.server.BaseHTTPRequestHandler): self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Access-Control-Allow-Methods', '*') self.send_header('Access-Control-Allow-Headers', '*') - self.send_header('Content-type', 'application/json') + if "/klite.embd" in self.path: + self.send_header('Content-type', 'text/html') + else: + self.send_header('Content-type', 'application/json') return super(ServerRequestHandler, self).end_headers()