Merge pull request #4798 from open-webui/dev

fix: filter compatibility issue
This commit is contained in:
Timothy Jaeryang Baek 2024-08-22 01:14:34 +02:00 committed by GitHub
commit e2b7296786
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -525,9 +525,8 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
"chat_id": body.pop("chat_id", None),
"message_id": body.pop("id", None),
"session_id": body.pop("session_id", None),
"valves": body.pop("valves", None),
"tool_ids": body.pop("tool_ids", None),
"files": body.pop("files", None),
"tool_ids": body.get("tool_ids", None),
"files": body.get("files", None),
}
body["metadata"] = metadata
@ -560,6 +559,13 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
content={"detail": str(e)},
)
metadata = {
**metadata,
"tool_ids": body.pop("tool_ids", None),
"files": body.pop("files", None),
}
body["metadata"] = metadata
try:
body, flags = await chat_completion_tools_handler(body, user, extra_params)
contexts.extend(flags.get("contexts", []))