Skip to content

Commit 3aba442

Browse files
committed
fix (chat): resolving buffering issues (WIP)
1 parent 03ff67e commit 3aba442

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/server/main/chat/routes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ async def event_stream_generator():
5656
continue
5757
# yield as bytes and flush
5858
yield json.dumps(event) + "\n"
59-
await asyncio.sleep(0.1) # Yield control to the event loop
6059
except asyncio.CancelledError:
6160
logger.info(f"Client disconnected, stream cancelled for user {user_id}.")
6261
except Exception as e:

src/server/nginx.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ server {
1414
# Location block for your chat stream
1515
location /chat/message {
1616
proxy_pass http://backend_app;
17+
proxy_set_header Host $host;
18+
proxy_set_header X-Real-IP $remote_addr;
19+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20+
proxy_set_header X-Forwarded-Proto $scheme;
21+
22+
proxy_read_timeout 86400s; # Prevent timeout during long LLM responses
23+
proxy_send_timeout 86400s;
1724

1825
# Prevent buffering
1926
proxy_buffering off;

0 commit comments

Comments
 (0)