# frozen_string_literal: true

module OpenAI
  module Models
    module Chat
      class ChatCompletionAssistantMessageParam < OpenAI::Internal::Type::BaseModel
        # @!attribute role
        #   The role of the messages author, in this case `assistant`.
        #
        #   @return [Symbol, :assistant]
        required :role, const: :assistant

        # @!attribute audio
        #   Data about a previous audio response from the model.
        #   [Learn more](https://platform.openai.com/docs/guides/audio).
        #
        #   @return [OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio, nil]
        optional :audio, -> { OpenAI::Chat::ChatCompletionAssistantMessageParam::Audio }, nil?: true

        # @!attribute content
        #   The contents of the assistant message. Required unless `tool_calls` or
        #   `function_call` is specified.
        #
        #   @return [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal>, nil]
        optional :content,
                 union: -> {
                   OpenAI::Chat::ChatCompletionAssistantMessageParam::Content
                 },
                 nil?: true

        # @!attribute function_call
        #   @deprecated
        #
        #   Deprecated and replaced by `tool_calls`. The name and arguments of a function
        #   that should be called, as generated by the model.
        #
        #   @return [OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall, nil]
        optional :function_call,
                 -> { OpenAI::Chat::ChatCompletionAssistantMessageParam::FunctionCall },
                 nil?: true

        # @!attribute name
        #   An optional name for the participant. Provides the model information to
        #   differentiate between participants of the same role.
        #
        #   @return [String, nil]
        optional :name, String

        # @!attribute refusal
        #   The refusal message by the assistant.
        #
        #   @return [String, nil]
        optional :refusal, String, nil?: true

        # @!attribute tool_calls
        #   The tool calls generated by the model, such as function calls.
        #
        #   @return [Array<OpenAI::Models::Chat::ChatCompletionMessageFunctionToolCall, OpenAI::Models::Chat::ChatCompletionMessageCustomToolCall>, nil]
        optional :tool_calls,
                 -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Chat::ChatCompletionMessageToolCall] }

        # @!method initialize(audio: nil, content: nil, function_call: nil, name: nil, refusal: nil, tool_calls: nil, role: :assistant)
        #   Some parameter documentations has been truncated, see
        #   {OpenAI::Models::Chat::ChatCompletionAssistantMessageParam} for more details.
        #
        #   Messages sent by the model in response to user messages.
        #
        #   @param audio [OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio, nil] Data about a previous audio response from the model.
        #
        #   @param content [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal>, nil] The contents of the assistant message. Required unless `tool_calls` or `function
        #
        #   @param function_call [OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall, nil] Deprecated and replaced by `tool_calls`. The name and arguments of a function th
        #
        #   @param name [String] An optional name for the participant. Provides the model information to differen
        #
        #   @param refusal [String, nil] The refusal message by the assistant.
        #
        #   @param tool_calls [Array<OpenAI::Models::Chat::ChatCompletionMessageFunctionToolCall, OpenAI::Models::Chat::ChatCompletionMessageCustomToolCall>] The tool calls generated by the model, such as function calls.
        #
        #   @param role [Symbol, :assistant] The role of the messages author, in this case `assistant`.

        # @see OpenAI::Models::Chat::ChatCompletionAssistantMessageParam#audio
        class Audio < OpenAI::Internal::Type::BaseModel
          # @!attribute id
          #   Unique identifier for a previous audio response from the model.
          #
          #   @return [String]
          required :id, String

          # @!method initialize(id:)
          #   Some parameter documentations has been truncated, see
          #   {OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio} for more
          #   details.
          #
          #   Data about a previous audio response from the model.
          #   [Learn more](https://platform.openai.com/docs/guides/audio).
          #
          #   @param id [String] Unique identifier for a previous audio response from the model.
        end

        # The contents of the assistant message. Required unless `tool_calls` or
        # `function_call` is specified.
        #
        # @see OpenAI::Models::Chat::ChatCompletionAssistantMessageParam#content
        module Content
          extend OpenAI::Internal::Type::Union

          # The contents of the assistant message.
          variant String

          # An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.
          variant -> { OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPartArray }

          # Learn about
          # [text inputs](https://platform.openai.com/docs/guides/text-generation).
          module ArrayOfContentPart
            extend OpenAI::Internal::Type::Union

            discriminator :type

            # Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
            variant :text, -> { OpenAI::Chat::ChatCompletionContentPartText }

            variant :refusal, -> { OpenAI::Chat::ChatCompletionContentPartRefusal }

            # @!method self.variants
            #   @return [Array(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal)]
          end

          # @!method self.variants
          #   @return [Array(String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal>)]

          # @type [OpenAI::Internal::Type::Converter]
          ArrayOfContentPartArray =
            OpenAI::Internal::Type::ArrayOf[union: -> {
              OpenAI::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPart
            }]
        end

        # @deprecated
        #
        # @see OpenAI::Models::Chat::ChatCompletionAssistantMessageParam#function_call
        class FunctionCall < 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

          # @!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::ChatCompletionAssistantMessageParam::FunctionCall} for
          #   more details.
          #
          #   Deprecated and replaced by `tool_calls`. The name and arguments of a function
          #   that should be called, as generated by the model.
          #
          #   @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

    ChatCompletionAssistantMessageParam = Chat::ChatCompletionAssistantMessageParam
  end
end
