enh: include sources field in non-streaming response

This commit is contained in:
Timothy Jaeryang Baek 2025-05-26 22:22:37 +04:00
parent ffa51ece0c
commit 2d5b82df8c

View File

@ -1217,8 +1217,34 @@ async def process_chat_response(
await background_tasks_handler() await background_tasks_handler()
if events and isinstance(events, list) and isinstance(response, dict):
extra_response = {}
for event in events:
if isinstance(event, dict):
extra_response.update(event)
else:
extra_response[event] = True
response = {
**extra_response,
**response,
}
return response return response
else: else:
if events and isinstance(events, list) and isinstance(response, dict):
extra_response = {}
for event in events:
if isinstance(event, dict):
extra_response.update(event)
else:
extra_response[event] = True
response = {
**extra_response,
**response,
}
return response return response
# Non standard response # Non standard response