added embedded copy of kobold lite

This commit is contained in:
Concedo 2023-03-21 20:41:19 +08:00
parent 8d39365af6
commit ff1c0c4898
2 changed files with 39 additions and 12 deletions

27
klite.embd Normal file

File diff suppressed because one or more lines are too long

View file

@ -80,34 +80,31 @@ modelbusy = False
port = 5001 port = 5001
last_context = "" last_context = ""
class ServerRequestHandler(http.server.BaseHTTPRequestHandler): class ServerRequestHandler(http.server.SimpleHTTPRequestHandler):
sys_version = "" sys_version = ""
server_version = "ConcedoLlamaForKoboldServer" server_version = "ConcedoLlamaForKoboldServer"
def do_GET(self): def do_GET(self):
if not self.path.endswith('/'): if self.path=="/":
# redirect browser self.path = "/klite.embd"
self.send_response(301) return http.server.SimpleHTTPRequestHandler.do_GET(self)
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.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.send_response(200)
self.end_headers() self.end_headers()
global friendlymodelname global friendlymodelname
self.wfile.write(json.dumps({"result": friendlymodelname }).encode()) self.wfile.write(json.dumps({"result": friendlymodelname }).encode())
return 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.send_response(200)
self.end_headers() self.end_headers()
global maxlen global maxlen
self.wfile.write(json.dumps({"value":maxlen}).encode()) self.wfile.write(json.dumps({"value":maxlen}).encode())
return 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.send_response(200)
self.end_headers() self.end_headers()
global maxctx global maxctx
@ -187,6 +184,9 @@ class ServerRequestHandler(http.server.BaseHTTPRequestHandler):
self.send_header('Access-Control-Allow-Origin', '*') self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', '*') self.send_header('Access-Control-Allow-Methods', '*')
self.send_header('Access-Control-Allow-Headers', '*') self.send_header('Access-Control-Allow-Headers', '*')
if "/klite.embd" in self.path:
self.send_header('Content-type', 'text/html')
else:
self.send_header('Content-type', 'application/json') self.send_header('Content-type', 'application/json')
return super(ServerRequestHandler, self).end_headers() return super(ServerRequestHandler, self).end_headers()