Skip to content

Commit 96ca0e1

Browse files
authored
Merge pull request alexrudall#435 from mpallenjr/patch-1
Update README.md
2 parents 3da217a + daa0a66 commit 96ca0e1

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

README.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -352,36 +352,39 @@ response =
352352
"content": "What is the weather like in San Francisco?",
353353
},
354354
],
355-
functions: [
355+
tools: [
356356
{
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],
357+
type: "function",
358+
function: {
359+
name: "get_current_weather",
360+
description: "Get the current weather in a given location",
361+
parameters: {
362+
type: :object,
363+
properties: {
364+
location: {
365+
type: :string,
366+
description: "The city and state, e.g. San Francisco, CA",
367+
},
368+
unit: {
369+
type: "string",
370+
enum: %w[celsius fahrenheit],
371+
},
369372
},
373+
required: ["location"],
370374
},
371-
required: ["location"],
372375
},
373-
},
376+
}
374377
],
375378
},
376379
)
377380

378381
message = response.dig("choices", 0, "message")
379382

380-
if message["role"] == "assistant" && message["function_call"]
381-
function_name = message.dig("function_call", "name")
383+
if message["role"] == "assistant" && message["tool_calls"]
384+
function_name = message.dig("tool_calls", "function", "name")
382385
args =
383386
JSON.parse(
384-
message.dig("function_call", "arguments"),
387+
message.dig("tool_calls", "function", "arguments"),
385388
{ symbolize_names: true },
386389
)
387390

0 commit comments

Comments
 (0)