Skip to content

Commit 69a6e9a

Browse files
author
harvey_xiang
committed
feat: update log
1 parent 5b962e2 commit 69a6e9a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/memos/api/middleware/request_context.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,16 @@ async def dispatch(self, request: Request, call_next: Callable) -> Response:
8282
# Process the request
8383
response = await call_next(request)
8484
end_time = time.time()
85-
content = _tee_stream(response)
85+
if isinstance(response, StreamingResponse):
86+
response.body_iterator = _tee_stream(response)
87+
content = "Streaming response"
88+
else:
89+
try:
90+
content = (
91+
response.body.decode("utf-8") if hasattr(response, "body") else str(response)
92+
)
93+
except Exception as e:
94+
content = f"Unable to decode response content: {e!s}"
8695

8796
if response.status_code == 200:
8897
logger.info(

0 commit comments

Comments
 (0)