Changes.
This commit is contained in:
parent
6b5ba8ac6c
commit
5cfc2218fd
12
server.py
12
server.py
@ -26,7 +26,7 @@ class OllamaServer:
|
|||||||
while True:
|
while True:
|
||||||
chunk = await self.queues[request_id].get()
|
chunk = await self.queues[request_id].get()
|
||||||
yield chunk
|
yield chunk
|
||||||
if chunk['done']:
|
if chunk.get('done'):
|
||||||
break
|
break
|
||||||
|
|
||||||
async def serve(self):
|
async def serve(self):
|
||||||
@ -125,6 +125,10 @@ async def index_handler(request):
|
|||||||
index_template = index_template.replace("#client.py", client_py)
|
index_template = index_template.replace("#client.py", client_py)
|
||||||
return web.Response(text=index_template, content_type="text/html")
|
return web.Response(text=index_template, content_type="text/html")
|
||||||
|
|
||||||
|
async def not_found_handler(request):
|
||||||
|
print("not found:",request.path)
|
||||||
|
return web.json_response({"error":"not found"})
|
||||||
|
|
||||||
async def models_handler(self):
|
async def models_handler(self):
|
||||||
return web.json_response(server_manager.get_models())
|
return web.json_response(server_manager.get_models())
|
||||||
|
|
||||||
@ -133,9 +137,11 @@ app = web.Application()
|
|||||||
app.router.add_get("/", index_handler)
|
app.router.add_get("/", index_handler)
|
||||||
app.router.add_route('GET', '/publish', websocket_handler)
|
app.router.add_route('GET', '/publish', websocket_handler)
|
||||||
app.router.add_route('POST', '/api/chat', http_handler)
|
app.router.add_route('POST', '/api/chat', http_handler)
|
||||||
app.router.add_route('POST', '/v1/api/chat', http_handler)
|
app.router.add_route('POST', '/v1/chat', http_handler)
|
||||||
app.router.add_route('POST', '/v1/api/chat/completions', http_handler)
|
app.router.add_route('POST', '/v1/completions', http_handler)
|
||||||
|
app.router.add_route('POST', '/v1/chat/completions', http_handler)
|
||||||
app.router.add_route('GET', '/models', models_handler)
|
app.router.add_route('GET', '/models', models_handler)
|
||||||
|
app.router.add_route('*', '/{tail:.*}', not_found_handler)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
web.run_app(app, port=1984)
|
web.run_app(app, port=1984)
|
||||||
|
Loading…
Reference in New Issue
Block a user