Merge feature/agent-final-answer-first-char into dev
This commit is contained in:
commit
9d00bad5f2
@ -1,6 +1,7 @@
|
||||
"""Logging callback handler module."""
|
||||
|
||||
import logging
|
||||
import traceback
|
||||
from typing import Any, Optional, Dict, List
|
||||
from langchain_core.callbacks import BaseCallbackHandler
|
||||
from langchain_core.messages import BaseMessage
|
||||
@ -80,4 +81,8 @@ class LoggingCallbackHandler(BaseCallbackHandler):
|
||||
self, error: Exception, **kwargs: Any
|
||||
) -> None:
|
||||
"""Called when a tool invocation raises an error."""
|
||||
self.logger.error(f"❌ Tool Error: {error}")
|
||||
self.logger.error(
|
||||
"❌ Tool Error: %s\n%s",
|
||||
repr(error),
|
||||
"".join(traceback.format_exception(type(error), error, error.__traceback__)),
|
||||
)
|
||||
|
||||
@ -3,6 +3,7 @@ import os
|
||||
import asyncio
|
||||
import shutil
|
||||
import time
|
||||
import traceback
|
||||
from typing import Union, Optional, Any, List, Dict
|
||||
from fastapi import APIRouter, HTTPException, Header, Body
|
||||
from fastapi.responses import StreamingResponse
|
||||
@ -185,9 +186,11 @@ async def enhanced_generate_stream_response(
|
||||
await output_queue.put(("agent_done", None))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error in agent task: {e}")
|
||||
logger.error(f"Error in agent task: {e}\n{traceback.format_exc()}")
|
||||
# Send error information to the client
|
||||
await output_queue.put(("agent", f'data: {{"error": "{str(e)}"}}\n\n'))
|
||||
await output_queue.put(
|
||||
("agent", f"data: {json.dumps({'error': str(e)}, ensure_ascii=False)}\n\n")
|
||||
)
|
||||
# Send completion signal to ensure the output controller exits normally
|
||||
await output_queue.put(("agent_done", None))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user