forked from open-webui/open-webui
fix: only edit body with whitelisted paths
This commit is contained in:
parent
6c58bb59be
commit
dfcc314283
1 changed files with 5 additions and 1 deletions
|
@ -62,8 +62,12 @@ async def on_startup():
|
||||||
class RAGMiddleware(BaseHTTPMiddleware):
|
class RAGMiddleware(BaseHTTPMiddleware):
|
||||||
async def dispatch(self, request: Request, call_next):
|
async def dispatch(self, request: Request, call_next):
|
||||||
|
|
||||||
|
"chat/completions" in request.url.path
|
||||||
|
|
||||||
print(request.url.path)
|
print(request.url.path)
|
||||||
if request.method == "POST":
|
if request.method == "POST" and (
|
||||||
|
"/api/chat" in request.url.path or "/chat/completions" in request.url.path
|
||||||
|
):
|
||||||
# Read the original request body
|
# Read the original request body
|
||||||
body = await request.body()
|
body = await request.body()
|
||||||
# Decode body to string
|
# Decode body to string
|
||||||
|
|
Loading…
Reference in a new issue