Skip to content

Commit 0fc3d22

Browse files
authored
Update README.md
Closes alexrudall#429
1 parent 7666e30 commit 0fc3d22

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
@@ -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

376379
message = 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

Comments
 (0)