# frozen_string_literal: true

module OpenAI
  module Models
    module Chat
      class ChatCompletionMessageFunctionToolCall < OpenAI::Internal::Type::BaseModel
        # @!attribute id
        #   The ID of the tool call.
        #
        #   @return [String]
        required :id, String

        # @!attribute function
        #   The function that the model called.
        #
        #   @return [OpenAI::Models::Chat::ChatCompletionMessageFunctionToolCall::Function]
        required :function, -> { OpenAI::Chat::ChatCompletionMessageFunctionToolCall::Function }

        # @!attribute type
        #   The type of the tool. Currently, only `function` is supported.
        #
        #   @return [Symbol, :function]
        required :type, const: :function

        # @!method initialize(id:, function:, type: :function)
        #   A call to a function tool created by the model.
        #
        #   @param id [String] The ID of the tool call.
        #
        #   @param function [OpenAI::Models::Chat::ChatCompletionMessageFunctionToolCall::Function] The function that the model called.
        #
        #   @param type [Symbol, :function] The type of the tool. Currently, only `function` is supported.

        # @see OpenAI::Models::Chat::ChatCompletionMessageFunctionToolCall#function
        class Function < OpenAI::Internal::Type::BaseModel
          # @!attribute arguments
          #   The arguments to call the function with, as generated by the model in JSON
          #   format. Note that the model does not always generate valid JSON, and may
          #   hallucinate parameters not defined by your function schema. Validate the
          #   arguments in your code before calling your function.
          #
          #   @return [String]
          required :arguments, String

          response_only do
            # @!attribute parsed
            #   The parsed contents of the arguments.
            #
            #   @return [Object, nil]
            required :parsed, OpenAI::StructuredOutput::ParsedJson
          end

          # @!attribute name
          #   The name of the function to call.
          #
          #   @return [String]
          required :name, String

          # @!method initialize(arguments:, name:)
          #   Some parameter documentations has been truncated, see
          #   {OpenAI::Models::Chat::ChatCompletionMessageFunctionToolCall::Function} for more
          #   details.
          #
          #   The function that the model called.
          #
          #   @param arguments [String] The arguments to call the function with, as generated by the model in JSON forma
          #
          #   @param name [String] The name of the function to call.
        end
      end
    end

    ChatCompletionMessageFunctionToolCall = Chat::ChatCompletionMessageFunctionToolCall
  end
end
