From 3346822e894ffb23c38b12440679d52aaa478507 Mon Sep 17 00:00:00 2001 From: LanQian <5499636+LanQian528@users.noreply.github.com> Date: Sun, 21 Apr 2024 13:42:02 +0800 Subject: [PATCH] feat reverse_proxy --- app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index be1e660..af73f95 100644 --- a/app.py +++ b/app.py @@ -41,7 +41,10 @@ async def send_conversation(request: Request, token=Depends(verify_token)): @app.api_route("/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "PATCH", "TRACE"]) async def reverse_proxy(request: Request, path: str): base_url = random.choice(chatgpt_base_url_list) - origin_url = request.url.scheme + "://" + request.url.netloc + if "http://" in str(request.url): + origin_url = "http://" + request.url.netloc + else: + origin_url = "https://" + request.url.netloc if "v1" in path: base_url = "https://ab.chatgpt.com" params = dict(request.query_params)