From 6cf4ebb25ab37430720c11fb552edc8a8cffaa2a Mon Sep 17 00:00:00 2001 From: Barbariskaa <129290831+Barbariskaa@users.noreply.github.com> Date: Sat, 3 Jun 2023 00:52:07 +0300 Subject: [PATCH] Add files via upload --- main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index bd5278a..98642c9 100644 --- a/main.py +++ b/main.py @@ -392,8 +392,15 @@ class SSEHandler(web.View): "temperature": 0.7, "stream": stream } + if REDIRECT_PROXY.endswith("v1/chat/completions") or REDIRECT_PROXY.endswith("v1/chat/completions/"): + url = REDIRECT_PROXY + elif REDIRECT_PROXY.endswith("/"): + url = f"{REDIRECT_PROXY}v1/chat/completions" + else: + url = f"{REDIRECT_PROXY}/v1/chat/completions" + print(url) # Use await to wait for the response - async with session.post(REDIRECT_PROXY, headers=headers, json=body) as response: + async with session.post(url, headers=headers, json=body) as response: # Use async for to iterate over the response chunks async for chunk in response.content.iter_chunked(1024): await self.response.write(chunk)