6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/models/raif/concerns/llms/open_ai_responses/response_tool_calls.rb', line 6
def (resp)
return if resp["output"].blank?
tool_calls = []
resp["output"].each do |output_item|
next unless output_item["type"] == "function_call"
tool_calls << {
"provider_tool_call_id" => output_item["call_id"],
"name" => output_item["name"],
"arguments" => begin
JSON.parse(output_item["arguments"])
rescue JSON::ParserError
output_item["arguments"]
end
}
end
tool_calls.any? ? tool_calls : nil
end
|