@@ -350,36 +350,39 @@ response =
350
350
" content" : " What is the weather like in San Francisco?" ,
351
351
},
352
352
],
353
- functions : [
353
+ tools : [
354
354
{
355
- name: " get_current_weather" ,
356
- description: " Get the current weather in a given location" ,
357
- parameters: {
358
- type: :object ,
359
- properties: {
360
- location: {
361
- type: :string ,
362
- description: " The city and state, e.g. San Francisco, CA" ,
363
- },
364
- unit: {
365
- type: " string" ,
366
- enum: %w[celsius fahrenheit] ,
355
+ type: " function" ,
356
+ " function" : {
357
+ name: " get_current_weather" ,
358
+ description: " Get the current weather in a given location" ,
359
+ parameters: {
360
+ type: :object ,
361
+ properties: {
362
+ location: {
363
+ type: :string ,
364
+ description: " The city and state, e.g. San Francisco, CA" ,
365
+ },
366
+ unit: {
367
+ type: " string" ,
368
+ enum: %w[celsius fahrenheit] ,
369
+ },
367
370
},
371
+ required: [" location" ],
368
372
},
369
- required: [" location" ],
370
373
},
371
- },
374
+ }
372
375
],
373
376
},
374
377
)
375
378
376
379
message = response.dig(" choices" , 0 , " message" )
377
380
378
- if message[" role" ] == " assistant" && message[" function_call " ]
379
- function_name = message.dig(" function_call " , " name" )
381
+ if message[" role" ] == " assistant" && message[" tool_calls " ]
382
+ function_name = message.dig(" tool_calls " , " function " , " name" )
380
383
args =
381
384
JSON .parse(
382
- message.dig(" function_call " , " arguments" ),
385
+ message.dig(" tool_calls " , " function " , " arguments" ),
383
386
{ symbolize_names: true },
384
387
)
385
388
0 commit comments