Module: Raif::Concerns::Llms::Anthropic::ResponseToolCalls
- Extended by:
- ActiveSupport::Concern
- Included in:
- Llms::Anthropic
- Defined in:
- app/models/raif/concerns/llms/anthropic/response_tool_calls.rb
Instance Method Summary collapse
Instance Method Details
#extract_response_tool_calls(resp) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/raif/concerns/llms/anthropic/response_tool_calls.rb', line 6 def extract_response_tool_calls(resp) return if resp&.dig("content").nil? # Find any tool_use content blocks tool_uses = resp&.dig("content")&.select do |content| content["type"] == "tool_use" end return if tool_uses.blank? tool_uses.map do |tool_use| { "provider_tool_call_id" => tool_use["id"], "name" => tool_use["name"], "arguments" => tool_use["input"], } end end |