# frozen_string_literal: true

module OpenAI
  module Models
    module Graders
      class ScoreModelGrader < OpenAI::Internal::Type::BaseModel
        # @!attribute input
        #   The input text. This may include template strings.
        #
        #   @return [Array<OpenAI::Models::Graders::ScoreModelGrader::Input>]
        required :input, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Graders::ScoreModelGrader::Input] }

        # @!attribute model
        #   The model to use for the evaluation.
        #
        #   @return [String]
        required :model, String

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

        # @!attribute type
        #   The object type, which is always `score_model`.
        #
        #   @return [Symbol, :score_model]
        required :type, const: :score_model

        # @!attribute range
        #   The range of the score. Defaults to `[0, 1]`.
        #
        #   @return [Array<Float>, nil]
        optional :range, OpenAI::Internal::Type::ArrayOf[Float]

        # @!attribute sampling_params
        #   The sampling parameters for the model.
        #
        #   @return [OpenAI::Models::Graders::ScoreModelGrader::SamplingParams, nil]
        optional :sampling_params, -> { OpenAI::Graders::ScoreModelGrader::SamplingParams }

        # @!method initialize(input:, model:, name:, range: nil, sampling_params: nil, type: :score_model)
        #   A ScoreModelGrader object that uses a model to assign a score to the input.
        #
        #   @param input [Array<OpenAI::Models::Graders::ScoreModelGrader::Input>] The input text. This may include template strings.
        #
        #   @param model [String] The model to use for the evaluation.
        #
        #   @param name [String] The name of the grader.
        #
        #   @param range [Array<Float>] The range of the score. Defaults to `[0, 1]`.
        #
        #   @param sampling_params [OpenAI::Models::Graders::ScoreModelGrader::SamplingParams] The sampling parameters for the model.
        #
        #   @param type [Symbol, :score_model] The object type, which is always `score_model`.

        class Input < OpenAI::Internal::Type::BaseModel
          # @!attribute content
          #   Inputs to the model - can contain template strings.
          #
          #   @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::InputImage, OpenAI::Models::Responses::ResponseInputAudio, Array<Object>]
          required :content, union: -> { OpenAI::Graders::ScoreModelGrader::Input::Content }

          # @!attribute role
          #   The role of the message input. One of `user`, `assistant`, `system`, or
          #   `developer`.
          #
          #   @return [Symbol, OpenAI::Models::Graders::ScoreModelGrader::Input::Role]
          required :role, enum: -> { OpenAI::Graders::ScoreModelGrader::Input::Role }

          # @!attribute type
          #   The type of the message input. Always `message`.
          #
          #   @return [Symbol, OpenAI::Models::Graders::ScoreModelGrader::Input::Type, nil]
          optional :type, enum: -> { OpenAI::Graders::ScoreModelGrader::Input::Type }

          # @!method initialize(content:, role:, type: nil)
          #   Some parameter documentations has been truncated, see
          #   {OpenAI::Models::Graders::ScoreModelGrader::Input} for more details.
          #
          #   A message input to the model with a role indicating instruction following
          #   hierarchy. Instructions given with the `developer` or `system` role take
          #   precedence over instructions given with the `user` role. Messages with the
          #   `assistant` role are presumed to have been generated by the model in previous
          #   interactions.
          #
          #   @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::InputImage, OpenAI::Models::Responses::ResponseInputAudio, Array<Object>] Inputs to the model - can contain template strings.
          #
          #   @param role [Symbol, OpenAI::Models::Graders::ScoreModelGrader::Input::Role] The role of the message input. One of `user`, `assistant`, `system`, or
          #
          #   @param type [Symbol, OpenAI::Models::Graders::ScoreModelGrader::Input::Type] The type of the message input. Always `message`.

          # Inputs to the model - can contain template strings.
          #
          # @see OpenAI::Models::Graders::ScoreModelGrader::Input#content
          module Content
            extend OpenAI::Internal::Type::Union

            # A text input to the model.
            variant String

            # A text input to the model.
            variant -> { OpenAI::Responses::ResponseInputText }

            # A text output from the model.
            variant -> { OpenAI::Graders::ScoreModelGrader::Input::Content::OutputText }

            # An image input to the model.
            variant -> { OpenAI::Graders::ScoreModelGrader::Input::Content::InputImage }

            # An audio input to the model.
            variant -> { OpenAI::Responses::ResponseInputAudio }

            # A list of inputs, each of which may be either an input text, input image, or input audio object.
            variant -> { OpenAI::Models::Graders::ScoreModelGrader::Input::Content::AnArrayOfInputTextInputImageAndInputAudioArray }

            class OutputText < OpenAI::Internal::Type::BaseModel
              # @!attribute text
              #   The text output from the model.
              #
              #   @return [String]
              required :text, String

              # @!attribute type
              #   The type of the output text. Always `output_text`.
              #
              #   @return [Symbol, :output_text]
              required :type, const: :output_text

              # @!method initialize(text:, type: :output_text)
              #   Some parameter documentations has been truncated, see
              #   {OpenAI::Models::Graders::ScoreModelGrader::Input::Content::OutputText} for more
              #   details.
              #
              #   A text output from the model.
              #
              #   @param text [String] The text output from the model.
              #
              #   @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
            end

            class InputImage < OpenAI::Internal::Type::BaseModel
              # @!attribute image_url
              #   The URL of the image input.
              #
              #   @return [String]
              required :image_url, String

              # @!attribute type
              #   The type of the image input. Always `input_image`.
              #
              #   @return [Symbol, :input_image]
              required :type, const: :input_image

              # @!attribute detail
              #   The detail level of the image to be sent to the model. One of `high`, `low`, or
              #   `auto`. Defaults to `auto`.
              #
              #   @return [String, nil]
              optional :detail, String

              # @!method initialize(image_url:, detail: nil, type: :input_image)
              #   Some parameter documentations has been truncated, see
              #   {OpenAI::Models::Graders::ScoreModelGrader::Input::Content::InputImage} for more
              #   details.
              #
              #   An image input to the model.
              #
              #   @param image_url [String] The URL of the image input.
              #
              #   @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
              #
              #   @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
            end

            # @!method self.variants
            #   @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::InputImage, OpenAI::Models::Responses::ResponseInputAudio, Array<Object>)]

            # @type [OpenAI::Internal::Type::Converter]
            AnArrayOfInputTextInputImageAndInputAudioArray =
              OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
          end

          # The role of the message input. One of `user`, `assistant`, `system`, or
          # `developer`.
          #
          # @see OpenAI::Models::Graders::ScoreModelGrader::Input#role
          module Role
            extend OpenAI::Internal::Type::Enum

            USER = :user
            ASSISTANT = :assistant
            SYSTEM = :system
            DEVELOPER = :developer

            # @!method self.values
            #   @return [Array<Symbol>]
          end

          # The type of the message input. Always `message`.
          #
          # @see OpenAI::Models::Graders::ScoreModelGrader::Input#type
          module Type
            extend OpenAI::Internal::Type::Enum

            MESSAGE = :message

            # @!method self.values
            #   @return [Array<Symbol>]
          end
        end

        # @see OpenAI::Models::Graders::ScoreModelGrader#sampling_params
        class SamplingParams < OpenAI::Internal::Type::BaseModel
          # @!attribute max_completions_tokens
          #   The maximum number of tokens the grader model may generate in its response.
          #
          #   @return [Integer, nil]
          optional :max_completions_tokens, Integer, nil?: true

          # @!attribute reasoning_effort
          #   Constrains effort on reasoning for
          #   [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
          #   supported values are `minimal`, `low`, `medium`, and `high`. Reducing reasoning
          #   effort can result in faster responses and fewer tokens used on reasoning in a
          #   response.
          #
          #   Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning
          #   effort.
          #
          #   @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
          optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true

          # @!attribute seed
          #   A seed value to initialize the randomness, during sampling.
          #
          #   @return [Integer, nil]
          optional :seed, Integer, nil?: true

          # @!attribute temperature
          #   A higher temperature increases randomness in the outputs.
          #
          #   @return [Float, nil]
          optional :temperature, Float, nil?: true

          # @!attribute top_p
          #   An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
          #
          #   @return [Float, nil]
          optional :top_p, Float, nil?: true

          # @!method initialize(max_completions_tokens: nil, reasoning_effort: nil, seed: nil, temperature: nil, top_p: nil)
          #   Some parameter documentations has been truncated, see
          #   {OpenAI::Models::Graders::ScoreModelGrader::SamplingParams} for more details.
          #
          #   The sampling parameters for the model.
          #
          #   @param max_completions_tokens [Integer, nil] The maximum number of tokens the grader model may generate in its response.
          #
          #   @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] Constrains effort on reasoning for
          #
          #   @param seed [Integer, nil] A seed value to initialize the randomness, during sampling.
          #
          #   @param temperature [Float, nil] A higher temperature increases randomness in the outputs.
          #
          #   @param top_p [Float, nil] An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
        end
      end
    end

    ScoreModelGrader = Graders::ScoreModelGrader
  end
end
