@@ -350,36 +350,39 @@ response =
350350 " content" : " What is the weather like in San Francisco?" ,
351351 },
352352 ],
353- functions : [
353+ tools : [
354354 {
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+ },
367370 },
371+ required: [" location" ],
368372 },
369- required: [" location" ],
370373 },
371- },
374+ }
372375 ],
373376 },
374377 )
375378
376379message = response.dig(" choices" , 0 , " message" )
377380
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" )
380383 args =
381384 JSON .parse(
382- message.dig(" function_call " , " arguments" ),
385+ message.dig(" tool_calls " , " function " , " arguments" ),
383386 { symbolize_names: true },
384387 )
385388
0 commit comments