* Helper function to sanitize tool calls to remove Unicode characters
(toolCalls: any)
| 330 | * Helper function to sanitize tool calls to remove Unicode characters |
| 331 | */ |
| 332 | function sanitizeToolCalls(toolCalls: any) { |
| 333 | // If it's an object with a list property, sanitize the list |
| 334 | if (toolCalls && typeof toolCalls === 'object' && Array.isArray(toolCalls.list)) { |
| 335 | return { |
| 336 | ...toolCalls, |
| 337 | list: toolCalls.list.map(sanitizeToolCall), |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | // If it's an array, sanitize each item |
| 342 | if (Array.isArray(toolCalls)) { |
| 343 | return toolCalls.map(sanitizeToolCall) |
| 344 | } |
| 345 | |
| 346 | return toolCalls |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * Sanitize a single tool call to remove Unicode characters |