This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-14 00:22:17 -06:00
1 parent f7767d6be7
commit a1579a01ff
6 files changed
+557 -110

No files matched your search

+14 -2
View File
@@ -927,7 +927,7 @@ async def _make_channel_emitter(request_info):
channel_id = request_info['chat_id'].removeprefix('channel:')
message_id = request_info['message_id']
state = {'last_emit_at': 0.0}
state = {'last_emit_at': 0.0, 'output': []}
THROTTLE_INTERVAL = 0.15 # ~6 updates/sec
async def _emit_channel_update(content: str, done: bool = False, output: list | None = None):
@@ -975,11 +975,23 @@ async def _make_channel_emitter(request_info):
if not content and not output and not done:
return
now = __import__('time').time()
now = time.time()
if done or (now - state['last_emit_at']) >= THROTTLE_INTERVAL:
state['last_emit_at'] = now
await _emit_channel_update(content, done, output if isinstance(output, list) else None)
elif event_type == 'response:completion':
from open_webui.utils.middleware import handle_responses_streaming_event
data = event_data.get('data', {})
state['output'], _ = handle_responses_streaming_event(data, state['output'])
content = get_output_text(state['output'])
now = time.time()
if content and (now - state['last_emit_at']) >= THROTTLE_INTERVAL:
state['last_emit_at'] = now
await _emit_channel_update(content, False, state['output'])
elif event_type == 'chat:message:error':
error = event_data.get('data', {}).get('error', {})
error_content = error.get('content', 'An error occurred') if isinstance(error, dict) else str(error)