Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion deepeval/openai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def render_messages(
name = ""
arguments = ""

# Parse arguments JSON safely
parsed_arguments = {}
if arguments:
try:
parsed_arguments = json.loads(arguments)
except (json.JSONDecodeError, TypeError):
# If parsing fails, use the raw string or empty dict
parsed_arguments = arguments if isinstance(arguments, dict) else {}

messages_list.append(
{
"id": tool_call.get("id", ""),
Expand All @@ -145,7 +154,7 @@ def render_messages(
), # OpenAI uses 'id', not 'call_id'
"name": name,
"type": tool_type,
"arguments": json.loads(arguments),
"arguments": parsed_arguments,
}
)

Expand Down
Loading