Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit ·
f6b02f3
1
Parent(s): e8a3722
Prefer tool_calls or assistant message for example structure
Browse files- agent/tools/dataset_tools.py +15 -2
agent/tools/dataset_tools.py
CHANGED
|
@@ -287,10 +287,23 @@ def _format_messages_structure(messages_data: Any) -> str | None:
|
|
| 287 |
lines.append("**Tool results:** ✓ Present")
|
| 288 |
|
| 289 |
# Show example message structure
|
| 290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
lines.append("")
|
| 292 |
lines.append("**Example message structure:**")
|
| 293 |
-
example = messages_data[0]
|
| 294 |
for key, val in example.items():
|
| 295 |
if key == "content":
|
| 296 |
val_preview = (
|
|
|
|
| 287 |
lines.append("**Tool results:** ✓ Present")
|
| 288 |
|
| 289 |
# Show example message structure
|
| 290 |
+
# Priority: 1) message with tool_calls, 2) first assistant message, 3) first non-system message
|
| 291 |
+
example = None
|
| 292 |
+
for msg in messages_data:
|
| 293 |
+
if not isinstance(msg, dict):
|
| 294 |
+
continue
|
| 295 |
+
role = msg.get("role", "")
|
| 296 |
+
if "tool_calls" in msg or "function_call" in msg:
|
| 297 |
+
example = msg
|
| 298 |
+
break
|
| 299 |
+
if role == "assistant" and example is None:
|
| 300 |
+
example = msg
|
| 301 |
+
if role != "system" and example is None:
|
| 302 |
+
example = msg
|
| 303 |
+
|
| 304 |
+
if example:
|
| 305 |
lines.append("")
|
| 306 |
lines.append("**Example message structure:**")
|
|
|
|
| 307 |
for key, val in example.items():
|
| 308 |
if key == "content":
|
| 309 |
val_preview = (
|