Skip to content

Commit 30fba98

Browse files
Updated 'How to call functions with chat models' cookbook to use GPT-… (#2072)
1 parent 872c3ec commit 30fba98

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

examples/How_to_call_functions_with_chat_models.ipynb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
},
5252
{
5353
"cell_type": "code",
54-
"execution_count": 2,
54+
"execution_count": null,
5555
"id": "dab872c5",
5656
"metadata": {
5757
"ExecuteTime": {
@@ -66,7 +66,7 @@
6666
"from tenacity import retry, wait_random_exponential, stop_after_attempt\n",
6767
"from termcolor import colored \n",
6868
"\n",
69-
"GPT_MODEL = \"gpt-4o\"\n",
69+
"GPT_MODEL = \"gpt-5\"\n",
7070
"client = OpenAI()"
7171
]
7272
},
@@ -515,7 +515,7 @@
515515
"source": [
516516
"### Parallel Function Calling\n",
517517
"\n",
518-
"Newer models such as gpt-4o or gpt-3.5-turbo can call multiple functions in one turn."
518+
"Newer models such as gpt-5, gpt-4.1 or gpt-4o can call multiple functions in one turn."
519519
]
520520
},
521521
{
@@ -758,7 +758,7 @@
758758
"source": [
759759
"##### Steps to invoke a function call using Chat Completions API: \n",
760760
"\n",
761-
"**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",
761+
"**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",
762762
" \n",
763763
"**Step 2**: Check programmatically if model wanted to call a function. If true, proceed to step 3. <br> \n",
764764
"**Step 3**: Extract the function name and parameters from response, call the function with parameters. Append the result to messages. <br> \n",
@@ -767,7 +767,7 @@
767767
},
768768
{
769769
"cell_type": "code",
770-
"execution_count": 19,
770+
"execution_count": null,
771771
"id": "e8b7cb9cdc7a7616",
772772
"metadata": {
773773
"ExecuteTime": {
@@ -792,9 +792,9 @@
792792
"}]\n",
793793
"\n",
794794
"response = client.chat.completions.create(\n",
795-
" model='gpt-4o', \n",
795+
" model=GPT_MODEL, \n",
796796
" messages=messages, \n",
797-
" tools= tools, \n",
797+
" tools=tools, \n",
798798
" tool_choice=\"auto\"\n",
799799
")\n",
800800
"\n",
@@ -807,7 +807,7 @@
807807
},
808808
{
809809
"cell_type": "code",
810-
"execution_count": 20,
810+
"execution_count": null,
811811
"id": "351c39def3417776",
812812
"metadata": {
813813
"ExecuteTime": {
@@ -847,7 +847,7 @@
847847
" # Step 4: Invoke the chat completions API with the function response appended to the messages list\n",
848848
" # Note that messages with role 'tool' must be a response to a preceding message with 'tool_calls'\n",
849849
" model_response_with_function_call = client.chat.completions.create(\n",
850-
" model=\"gpt-4o\",\n",
850+
" model=GPT_MODEL,\n",
851851
" messages=messages,\n",
852852
" ) # get a new response from the model where it can see the function response\n",
853853
" print(model_response_with_function_call.choices[0].message.content)\n",

0 commit comments

Comments
 (0)