Class: OpenAI::Models::Chat::ChatCompletionChunk::Moderation::Output::ModerationResults::Result

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/openai/models/chat/chat_completion_chunk.rb,
sig/openai/models/chat/chat_completion_chunk.rbs

Defined Under Namespace

Modules: CategoryAppliedInputType

Instance Attribute Summary collapse

Attributes inherited from Internal::Type::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Internal::Type::BaseModel

==, #==, #[], #_request_id, #_set_last_response, coerce, #deconstruct_keys, #deep_to_h, dump, #encode_with, fields, hash, #hash, inherited, #inspect, inspect, known_fields, optional, recursively_to_h, required, #to_h, #to_json, #to_s, to_sorbet_type, #to_yaml

Methods included from Internal::Type::Converter

#coerce, coerce, coerce_with_error, dump, #dump, #inspect, inspect, meta_info, new_coerce_state, type_info

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Constructor Details

#initialize(model:, results:, type: :moderation_results) ⇒ Object

Parameters:

  • categories —

    A dictionary of moderation categories to booleans, True if the input is flagged under this category.

  • category_applied_input_types —

    Which modalities of input are reflected by the score for each category.

  • category_scores —

    A dictionary of moderation categories to scores.

  • flagged —

    A boolean indicating whether the content was flagged by any category.

  • model —

    The moderation model that produced this result.

  • type (defaults to: :moderation_results) —

    The object type, which was always moderation_result for successful moderation results.



711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 711

class Result < OpenAI::Internal::Type::BaseModel
  # @!attribute categories
  #   A dictionary of moderation categories to booleans, True if the input is flagged
  #   under this category.
  #
  #   @return [Hash{Symbol=>Boolean}]
  required :categories, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Boolean]

  # @!attribute category_applied_input_types
  #   Which modalities of input are reflected by the score for each category.
  #
  #   @return [Hash{Symbol=>Array<Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType>}]
  required(
    :category_applied_input_types,
    -> do
      OpenAI::Internal::Type::HashOf[
        OpenAI::Internal::Type::ArrayOf[
          enum: OpenAI::Chat::ChatCompletionChunk::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType
        ]
      ]
    end
  )

  # @!attribute category_scores
  #   A dictionary of moderation categories to scores.
  #
  #   @return [Hash{Symbol=>Float}]
  required :category_scores, OpenAI::Internal::Type::HashOf[Float]

  # @!attribute flagged
  #   A boolean indicating whether the content was flagged by any category.
  #
  #   @return [Boolean]
  required :flagged, OpenAI::Internal::Type::Boolean

  # @!attribute model
  #   The moderation model that produced this result.
  #
  #   @return [String]
  required :model, String

  # @!attribute type
  #   The object type, which was always `moderation_result` for successful moderation
  #   results.
  #
  #   @return [Symbol, :moderation_result]
  required :type, const: :moderation_result

  # @!method initialize(categories:, category_applied_input_types:, category_scores:, flagged:, model:, type: :moderation_result)
  #   A moderation result produced for the response input or output.
  #
  #   @param categories [Hash{Symbol=>Boolean}]
  #     A dictionary of moderation categories to booleans, True if the input is flagged
  #     under this category.
  #
  #   @param category_applied_input_types [Hash{Symbol=>Array<Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType>}]
  #     Which modalities of input are reflected by the score for each category.
  #
  #   @param category_scores [Hash{Symbol=>Float}]
  #     A dictionary of moderation categories to scores.
  #
  #   @param flagged [Boolean]
  #     A boolean indicating whether the content was flagged by any category.
  #
  #   @param model [String]
  #     The moderation model that produced this result.
  #
  #   @param type [Symbol, :moderation_result]
  #     The object type, which was always `moderation_result` for successful moderation
  #     results.
  module CategoryAppliedInputType
    extend OpenAI::Internal::Type::Enum

    TEXT = :text
    IMAGE = :image

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

Instance Attribute Details

#categories ⇒ ::Hash[Symbol, bool]

A dictionary of moderation categories to booleans, True if the input is flagged under this category.

Returns:

  • (::Hash[Symbol, bool])


717
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 717

required :categories, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Boolean]

#category_applied_input_types ⇒ ::Hash[Symbol, ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Moderation::Output::ModerationResults::Result::category_applied_input_type]]

Which modalities of input are reflected by the score for each category.

Returns:

  • (::Hash[Symbol, ::Array[OpenAI::Models::Chat::ChatCompletionChunk::Moderation::Output::ModerationResults::Result::category_applied_input_type]])


723
724
725
726
727
728
729
730
731
732
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 723

required(
  :category_applied_input_types,
  -> do
    OpenAI::Internal::Type::HashOf[
      OpenAI::Internal::Type::ArrayOf[
        enum: OpenAI::Chat::ChatCompletionChunk::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType
      ]
    ]
  end
)

#category_scores ⇒ ::Hash[Symbol, Float]

A dictionary of moderation categories to scores.

Returns:

  • (::Hash[Symbol, Float])


738
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 738

required :category_scores, OpenAI::Internal::Type::HashOf[Float]

#flagged ⇒ Boolean

A boolean indicating whether the content was flagged by any category.

Returns:



744
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 744

required :flagged, OpenAI::Internal::Type::Boolean

#model ⇒ String

The moderation model that produced this result.

Returns:

  • (String)


750
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 750

required :model, String

#type ⇒ :moderation_result

The object type, which was always moderation_result for successful moderation results.

Returns:

  • (:moderation_result)


757
# File 'lib/openai/models/chat/chat_completion_chunk.rb', line 757

required :type, const: :moderation_result

Instance Method Details

#to_hash ⇒ {

Returns:

  • ({)


751
# File 'sig/openai/models/chat/chat_completion_chunk.rbs', line 751

def to_hash: -> {