Skip to content

Commit 64ea88b

Browse files
committed
feat: MCP mcp/mcp_question support param to disable streaming
1 parent 5c697f9 commit 64ea88b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

backend/common/core/response_middleware.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ async def dispatch(self, request, call_next):
1717
response = await call_next(request)
1818

1919
direct_paths = [
20-
f"{settings.API_V1_STR}/openapi.json",
2120
f"{settings.API_V1_STR}/mcp/mcp_question",
2221
f"{settings.API_V1_STR}/mcp/mcp_assistant"
2322
]
2423

2524
route = request.scope.get("route")
2625
# 获取定义的路径模式,例如 '/items/{item_id}'
27-
path_pattern = route.path_format
26+
path_pattern = '' if not route else route.path_format
2827

29-
if isinstance(response, JSONResponse) or path_pattern in direct_paths:
28+
if (isinstance(response, JSONResponse)
29+
or request.url.path == f"{settings.API_V1_STR}/openapi.json"
30+
or path_pattern in direct_paths):
3031
return response
3132
if response.status_code != 200:
3233
return response

0 commit comments

Comments
 (0)