Skip to content

Examples and guides for using the OpenAI API

Bugfix for reasoning-function-call notebook (#1800)

Tom Pakemancb43eb40e288
diff --git a/examples/reasoning_function_calls.ipynb b/examples/reasoning_function_calls.ipynb
index 2c264789..127de07e 100644
--- a/examples/reasoning_function_calls.ipynb
+++ b/examples/reasoning_function_calls.ipynb
@@ -317,15 +317,21 @@
" arguments = json.loads(response_item.arguments)\n",
" print(f\"Invoking tool: {response_item.name}({arguments})\")\n",
" tool_output = target_tool(**arguments)\n",
- " intermediate_messages.append({\n",
- " \"type\": \"function_call_output\",\n",
- " \"call_id\": response_item.call_id,\n",
- " \"output\": tool_output\n",
- " })\n",
" except Exception as e:\n",
- " tool_output = f\"Error executing function call: {function_call.name}: {e}\"\n",
+ " msg = f\"Error executing function call: {response_item.name}: {e}\"\n",
+ " tool_output = msg\n",
+ " print(msg)\n",
" else:\n",
- " print(f\"ERROR - No tool registered for function call: {function_call.name}\")\n",
+ " msg = f\"ERROR - No tool registered for function call: {response_item.name}\"\n",
+ " tool_output = msg\n",
+ " print(msg)\n",
+ " intermediate_messages.append({\n",
+ " \"type\": \"function_call_output\",\n",
+ " \"call_id\": response_item.call_id,\n",
+ " \"output\": tool_output\n",
+ " })\n",
+ " elif response_item.type == 'reasoning':\n",
+ " print(f'Reasoning step: {response_item.summary}')\n",
" return intermediate_messages"
]
},