parent
63a998bb1f
commit
5be0ab609e
@ -1,32 +1,66 @@
|
|||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
|
|
||||||
class ToolAgentError(Exception):
|
class ToolAgentError(Exception):
|
||||||
"""Base exception for all tool agent errors."""
|
"""Base exception for all tool agent errors."""
|
||||||
def __init__(self, message: str, details: Optional[Dict[str, Any]] = None):
|
|
||||||
|
def __init__(
|
||||||
|
self, message: str, details: Optional[Dict[str, Any]] = None
|
||||||
|
):
|
||||||
self.message = message
|
self.message = message
|
||||||
self.details = details or {}
|
self.details = details or {}
|
||||||
super().__init__(self.message)
|
super().__init__(self.message)
|
||||||
|
|
||||||
|
|
||||||
class ToolExecutionError(ToolAgentError):
|
class ToolExecutionError(ToolAgentError):
|
||||||
"""Raised when a tool fails to execute."""
|
"""Raised when a tool fails to execute."""
|
||||||
def __init__(self, tool_name: str, error: Exception, details: Optional[Dict[str, Any]] = None):
|
|
||||||
message = f"Failed to execute tool '{tool_name}': {str(error)}"
|
def __init__(
|
||||||
|
self,
|
||||||
|
tool_name: str,
|
||||||
|
error: Exception,
|
||||||
|
details: Optional[Dict[str, Any]] = None,
|
||||||
|
):
|
||||||
|
message = (
|
||||||
|
f"Failed to execute tool '{tool_name}': {str(error)}"
|
||||||
|
)
|
||||||
super().__init__(message, details)
|
super().__init__(message, details)
|
||||||
|
|
||||||
|
|
||||||
class ToolValidationError(ToolAgentError):
|
class ToolValidationError(ToolAgentError):
|
||||||
"""Raised when tool parameters fail validation."""
|
"""Raised when tool parameters fail validation."""
|
||||||
def __init__(self, tool_name: str, param_name: str, error: str, details: Optional[Dict[str, Any]] = None):
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
tool_name: str,
|
||||||
|
param_name: str,
|
||||||
|
error: str,
|
||||||
|
details: Optional[Dict[str, Any]] = None,
|
||||||
|
):
|
||||||
message = f"Validation error for tool '{tool_name}' parameter '{param_name}': {error}"
|
message = f"Validation error for tool '{tool_name}' parameter '{param_name}': {error}"
|
||||||
super().__init__(message, details)
|
super().__init__(message, details)
|
||||||
|
|
||||||
|
|
||||||
class ToolNotFoundError(ToolAgentError):
|
class ToolNotFoundError(ToolAgentError):
|
||||||
"""Raised when a requested tool is not found."""
|
"""Raised when a requested tool is not found."""
|
||||||
def __init__(self, tool_name: str, details: Optional[Dict[str, Any]] = None):
|
|
||||||
|
def __init__(
|
||||||
|
self, tool_name: str, details: Optional[Dict[str, Any]] = None
|
||||||
|
):
|
||||||
message = f"Tool '{tool_name}' not found"
|
message = f"Tool '{tool_name}' not found"
|
||||||
super().__init__(message, details)
|
super().__init__(message, details)
|
||||||
|
|
||||||
|
|
||||||
class ToolParameterError(ToolAgentError):
|
class ToolParameterError(ToolAgentError):
|
||||||
"""Raised when tool parameters are invalid."""
|
"""Raised when tool parameters are invalid."""
|
||||||
def __init__(self, tool_name: str, error: str, details: Optional[Dict[str, Any]] = None):
|
|
||||||
message = f"Invalid parameters for tool '{tool_name}': {error}"
|
def __init__(
|
||||||
|
self,
|
||||||
|
tool_name: str,
|
||||||
|
error: str,
|
||||||
|
details: Optional[Dict[str, Any]] = None,
|
||||||
|
):
|
||||||
|
message = (
|
||||||
|
f"Invalid parameters for tool '{tool_name}': {error}"
|
||||||
|
)
|
||||||
super().__init__(message, details)
|
super().__init__(message, details)
|
Loading…
Reference in new issue