|
317 | 317 | " arguments = json.loads(response_item.arguments)\n",
|
318 | 318 | " print(f\"Invoking tool: {response_item.name}({arguments})\")\n",
|
319 | 319 | " tool_output = target_tool(**arguments)\n",
|
320 |
| - " intermediate_messages.append({\n", |
321 |
| - " \"type\": \"function_call_output\",\n", |
322 |
| - " \"call_id\": response_item.call_id,\n", |
323 |
| - " \"output\": tool_output\n", |
324 |
| - " })\n", |
325 | 320 | " except Exception as e:\n",
|
326 |
| - " tool_output = f\"Error executing function call: {function_call.name}: {e}\"\n", |
| 321 | + " msg = f\"Error executing function call: {response_item.name}: {e}\"\n", |
| 322 | + " tool_output = msg\n", |
| 323 | + " print(msg)\n", |
327 | 324 | " else:\n",
|
328 |
| - " print(f\"ERROR - No tool registered for function call: {function_call.name}\")\n", |
| 325 | + " msg = f\"ERROR - No tool registered for function call: {response_item.name}\"\n", |
| 326 | + " tool_output = msg\n", |
| 327 | + " print(msg)\n", |
| 328 | + " intermediate_messages.append({\n", |
| 329 | + " \"type\": \"function_call_output\",\n", |
| 330 | + " \"call_id\": response_item.call_id,\n", |
| 331 | + " \"output\": tool_output\n", |
| 332 | + " })\n", |
| 333 | + " elif response_item.type == 'reasoning':\n", |
| 334 | + " print(f'Reasoning step: {response_item.summary}')\n", |
329 | 335 | " return intermediate_messages"
|
330 | 336 | ]
|
331 | 337 | },
|
|
0 commit comments