|
|
@ -2256,14 +2256,18 @@ class BaseTool(BaseModel):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
api_response = json.loads(api_response)
|
|
|
|
api_response = json.loads(api_response)
|
|
|
|
except json.JSONDecodeError as e:
|
|
|
|
except json.JSONDecodeError as e:
|
|
|
|
raise ToolValidationError(
|
|
|
|
self._log_if_verbose(
|
|
|
|
f"Invalid JSON in API response: {e}"
|
|
|
|
"error",
|
|
|
|
) from e
|
|
|
|
f"Failed to parse JSON from API response: {e}. Response: '{api_response[:100]}...'"
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
if not isinstance(api_response, dict):
|
|
|
|
if not isinstance(api_response, dict):
|
|
|
|
raise ToolValidationError(
|
|
|
|
self._log_if_verbose(
|
|
|
|
"API response must be a dictionary, JSON string, BaseModel, or list of tool calls"
|
|
|
|
"warning",
|
|
|
|
|
|
|
|
f"API response is not a dictionary (type: {type(api_response)}), returning empty list"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
|
|
# Extract function calls from dictionary response
|
|
|
|
# Extract function calls from dictionary response
|
|
|
|
function_calls = (
|
|
|
|
function_calls = (
|
|
|
|