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)