Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update README.md
  • Loading branch information
akimthedream authored Oct 17, 2024
commit b4d2936b0dc8858bc44150e826f41455fc27b1f2
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ response =
message = response.dig("choices", 0, "message")

if message["role"] == "assistant" && message["tool_calls"]

# For a subsequent message with the role "tool", OpenAI requires the preceding message to have a tool_calls argument.
messages << message

message["tool_calls"].each do |tool_call|
tool_call_id = tool_call.dig("id")
function_name = tool_call.dig("function", "name")
Expand All @@ -504,9 +508,6 @@ if message["role"] == "assistant" && message["tool_calls"]
# decide how to handle
end

# For a subsequent message with the role "tool", OpenAI requires the preceding message to have a tool_calls argument.
messages << message

messages << {
tool_call_id: tool_call_id,
role: "tool",
Expand Down