Skip to content

Commit d3ec5d7

Browse files
committed
handle non-json function data
1 parent 2659f6b commit d3ec5d7

File tree

1 file changed

+12
-2
lines changed
  • livekit-agents/livekit/agents/telemetry

1 file changed

+12
-2
lines changed

livekit-agents/livekit/agents/telemetry/traces.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,21 +245,31 @@ def _to_log_chat_item(item: ChatItem) -> map[str, any] | None:
245245
}
246246

247247
elif item.type == "function_call":
248+
try:
249+
arguments = json.loads(item.arguments)
250+
except:
251+
arguments = item.arguments
252+
248253
return {
249254
"type": item.type,
250255
"id": item.id,
251256
"call_id": item.call_id,
252-
"arguments": json.loads(item.arguments),
257+
"arguments": arguments,
253258
"name": item.name,
254259
}
255260

256261
elif item.type == "function_call_output":
262+
try:
263+
output = json.loads(item.output)
264+
except:
265+
output = item.output
266+
257267
return {
258268
"type": item.type,
259269
"id": item.id,
260270
"name": item.name,
261271
"call_id": item.call_id,
262-
"output": json.loads(item.output),
272+
"output": output,
263273
"is_error": item.is_error,
264274
}
265275

0 commit comments

Comments
 (0)