fix: error message persistence issue

This commit is contained in:
Timothy Jaeryang Baek
2025-03-28 00:25:00 -07:00
parent 2070d1096b
commit 2fc8ace46d
2 changed files with 18 additions and 3 deletions

View File

@@ -281,10 +281,10 @@ async def chat_completion_tools_handler(
await tool_call_handler(result)
except Exception as e:
log.exception(f"Error: {e}")
log.debug(f"Error: {e}")
content = None
except Exception as e:
log.exception(f"Error: {e}")
log.debug(f"Error: {e}")
content = None
log.debug(f"tool_contexts: {sources}")
@@ -1539,6 +1539,8 @@ async def process_chat_response(
try:
data = json.loads(data)
print(data)
data, _ = await process_filter_functions(
request=request,
filter_functions=filter_functions,
@@ -1560,6 +1562,16 @@ async def process_chat_response(
else:
choices = data.get("choices", [])
if not choices:
error = data.get("error", {})
if error:
await event_emitter(
{
"type": "chat:completion",
"data": {
"error": error,
},
}
)
usage = data.get("usage", {})
if usage:
await event_emitter(