Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions examples/How_to_call_functions_with_chat_models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "dab872c5",
"metadata": {
"ExecuteTime": {
Expand All @@ -66,7 +66,7 @@
"from tenacity import retry, wait_random_exponential, stop_after_attempt\n",
"from termcolor import colored \n",
"\n",
"GPT_MODEL = \"gpt-4o\"\n",
"GPT_MODEL = \"gpt-5\"\n",
"client = OpenAI()"
]
},
Expand Down Expand Up @@ -515,7 +515,7 @@
"source": [
"### Parallel Function Calling\n",
"\n",
"Newer models such as gpt-4o or gpt-3.5-turbo can call multiple functions in one turn."
"Newer models such as gpt-5, gpt-4o or gpt-3.5-turbo can call multiple functions in one turn."
]
},
{
Expand Down Expand Up @@ -758,7 +758,7 @@
"source": [
"##### Steps to invoke a function call using Chat Completions API: \n",
"\n",
"**Step 1**: Prompt the model with content that may result in model selecting a tool to use. The description of the tools such as a function names and signature is defined in the 'Tools' list and passed to the model in API call. If selected, the function name and parameters are included in the response.<br>\n",
"**Step 1**: Prompt the model with content that may result in model selecting a tool to use. The description of the tools such as a function name and signature is defined in the 'Tools' list and passed to the model in API call. If selected, the function name and parameters are included in the response.<br>\n",
" \n",
"**Step 2**: Check programmatically if model wanted to call a function. If true, proceed to step 3. <br> \n",
"**Step 3**: Extract the function name and parameters from response, call the function with parameters. Append the result to messages. <br> \n",
Expand All @@ -767,7 +767,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": null,
"id": "e8b7cb9cdc7a7616",
"metadata": {
"ExecuteTime": {
Expand All @@ -792,9 +792,9 @@
"}]\n",
"\n",
"response = client.chat.completions.create(\n",
" model='gpt-4o', \n",
" model=GPT_MODEL, \n",
" messages=messages, \n",
" tools= tools, \n",
" tools=tools, \n",
" tool_choice=\"auto\"\n",
")\n",
"\n",
Expand All @@ -807,7 +807,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"id": "351c39def3417776",
"metadata": {
"ExecuteTime": {
Expand Down Expand Up @@ -847,7 +847,7 @@
" # Step 4: Invoke the chat completions API with the function response appended to the messages list\n",
" # Note that messages with role 'tool' must be a response to a preceding message with 'tool_calls'\n",
" model_response_with_function_call = client.chat.completions.create(\n",
" model=\"gpt-4o\",\n",
" model=GPT_MODEL,\n",
" messages=messages,\n",
" ) # get a new response from the model where it can see the function response\n",
" print(model_response_with_function_call.choices[0].message.content)\n",
Expand Down