From 98b5614345d4a0f2191657e6423e33d644029402 Mon Sep 17 00:00:00 2001 From: nsde Date: Mon, 11 Sep 2023 02:47:21 +0200 Subject: [PATCH] =?UTF-8?q?I=20forgor=20=F0=9F=92=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/handler.py | 4 ++-- api/{streaming.py => responder.py} | 5 +---- api/types/user.py | 1 - 3 files changed, 3 insertions(+), 7 deletions(-) rename api/{streaming.py => responder.py} (98%) delete mode 100644 api/types/user.py diff --git a/api/handler.py b/api/handler.py index b0f852d..b829da6 100644 --- a/api/handler.py +++ b/api/handler.py @@ -9,7 +9,7 @@ import fastapi from dotenv import load_dotenv -import streaming +import responder import moderation from rich import print @@ -143,7 +143,7 @@ async def handle(incoming_request: fastapi.Request): media_type = 'text/event-stream' if payload.get('stream', False) else 'application/json' return fastapi.responses.StreamingResponse( - content=streaming.stream( + content=responder.respond( user=user, path=path, payload=payload, diff --git a/api/streaming.py b/api/responder.py similarity index 98% rename from api/streaming.py rename to api/responder.py index 117fea9..961c16f 100644 --- a/api/streaming.py +++ b/api/responder.py @@ -39,7 +39,7 @@ DEMO_PAYLOAD = { ] } -async def stream( +async def respond( path: str='/v1/chat/completions', user: dict=None, payload: dict=None, @@ -185,6 +185,3 @@ async def stream( ) print(f'[+] {path} -> {model or ""}') - -if __name__ == '__main__': - asyncio.run(stream()) diff --git a/api/types/user.py b/api/types/user.py deleted file mode 100644 index 339f360..0000000 --- a/api/types/user.py +++ /dev/null @@ -1 +0,0 @@ -## TODO: Create user type out of JSON object. \ No newline at end of file