-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Eval SDK] Fix argument type in agent response reformatting for evaluators #44897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -710,6 +710,15 @@ def reformat_conversation_history(query, logger=None, include_system_messages=Fa | |
| return query | ||
|
|
||
|
|
||
| def _format_value(v): | ||
| if isinstance(v, str): | ||
| return f'"{v}"' | ||
| elif v is None: | ||
| return "None" | ||
| else: | ||
| return str(v) | ||
|
Comment on lines
713
to
719
|
||
|
|
||
|
|
||
| def _get_agent_response(agent_response_msgs, include_tool_messages=False): | ||
| """Extracts formatted agent response including text, and optionally tool calls/results.""" | ||
| agent_response_text = [] | ||
|
|
@@ -743,7 +752,7 @@ def _get_agent_response(agent_response_msgs, include_tool_messages=False): | |
| tool_call_id = content.get("tool_call_id") | ||
| func_name = content.get("name", "") | ||
| args = content.get("arguments", {}) | ||
| args_str = ", ".join(f'{k}="{v}"' for k, v in args.items()) | ||
| args_str = ", ".join(f"{k}={_format_value(v)}" for k, v in args.items()) | ||
| call_line = f"[TOOL_CALL] {func_name}({args_str})" | ||
| agent_response_text.append(call_line) | ||
| if tool_call_id in tool_results: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
_format_valuefunction usesstr()for complex types (dicts, lists), which produces Python-style representations (e.g.,{'key': 'value'}instead of JSON-style{"key": "value"}). For tool call arguments that may contain nested structures, consider whetherjson.dumps()would be more appropriate to ensure consistent JSON-style formatting. This would produce output likeranking_options={"ranker": "default_2024_08_21", "score_threshold": 0.0}instead ofranking_options={'ranker': 'default_2024_08_21', 'score_threshold': 0.0}.