class RubyLLM::Providers::OpenAI

def parse_tool_calls(tool_calls, parse_arguments: true)

def parse_tool_calls(tool_calls, parse_arguments: true)
  return nil unless tool_calls&.any?
  tool_calls.to_h do |tc|
    [
      tc['id'],
      ToolCall.new(
        id: tc['id'],
        name: tc.dig('function', 'name'),
        arguments: parse_arguments ? JSON.parse(tc.dig('function', 'arguments')) : tc.dig('function', 'arguments')
      )
    ]
  end
end