Spaces:
Paused
Paused
Mirrowel
commited on
Commit
Β·
0ea3b2d
1
Parent(s):
74f9532
fix(proxy): π prevent role field concatenation in streaming responses
Browse filesThe generic key handling logic was incorrectly concatenating the 'role' field when processing streaming message chunks. The role field should always be replaced with the latest value, not concatenated like content fields.
This fix adds an explicit check to ensure the 'role' key is always overwritten rather than appended to, preventing malformed role values in the final message object.
- src/proxy_app/main.py +4 -1
src/proxy_app/main.py
CHANGED
|
@@ -589,7 +589,10 @@ async def streaming_response_wrapper(
|
|
| 589 |
final_message["function_call"]["arguments"] += value["arguments"]
|
| 590 |
|
| 591 |
else: # Generic key handling for other data like 'reasoning'
|
| 592 |
-
|
|
|
|
|
|
|
|
|
|
| 593 |
final_message[key] = value
|
| 594 |
elif isinstance(final_message.get(key), str):
|
| 595 |
final_message[key] += value
|
|
|
|
| 589 |
final_message["function_call"]["arguments"] += value["arguments"]
|
| 590 |
|
| 591 |
else: # Generic key handling for other data like 'reasoning'
|
| 592 |
+
# FIX: Role should always replace, never concatenate
|
| 593 |
+
if key == "role":
|
| 594 |
+
final_message[key] = value
|
| 595 |
+
elif key not in final_message:
|
| 596 |
final_message[key] = value
|
| 597 |
elif isinstance(final_message.get(key), str):
|
| 598 |
final_message[key] += value
|