Class: OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result

Inherits:
Internal::Type::BaseModel show all
Defined in:
lib/openai/models/chat/chat_completion.rb,
sig/openai/models/chat/chat_completion.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

Successful moderation results for the request input or generated output.

Parameters:



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/openai/models/chat/chat_completion.rb', line 295

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::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType>}]
  required(
    :category_applied_input_types,
    -> do
      OpenAI::Internal::Type::HashOf[
        OpenAI::Internal::Type::ArrayOf[
          enum: OpenAI::Chat::ChatCompletion::Moderation::Input::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)
  #   Some parameter documentations has been truncated, see
  #   {OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result}
  #   for more details.
  #
  #   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
  #
  #   @param category_applied_input_types [Hash{Symbol=>Array<Symbol, OpenAI::Models::Chat::ChatCompletion::Moderation::Input::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

  module CategoryAppliedInputType
    extend OpenAI::Internal::Type::Enum

    TEXT = :text
    IMAGE = :image

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

Instance Attribute Details

#categoriesHash{Symbol=>Boolean}

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

Parameters:

  • value (::Hash[Symbol, bool])

Returns:



301
# File 'lib/openai/models/chat/chat_completion.rb', line 301

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

#category_applied_input_typesHash{Symbol=>Array<Symbol, OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType>}

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

Parameters:

  • value (::Hash[Symbol, ::Array[OpenAI::Models::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::category_applied_input_type]])

Returns:



307
308
309
310
311
312
313
314
315
316
# File 'lib/openai/models/chat/chat_completion.rb', line 307

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

#category_scoresHash{Symbol=>Float}

A dictionary of moderation categories to scores.

Parameters:

  • value (::Hash[Symbol, Float])

Returns:

  • (Hash{Symbol=>Float})


322
# File 'lib/openai/models/chat/chat_completion.rb', line 322

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

#flaggedBoolean

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

Parameters:

Returns:



328
# File 'lib/openai/models/chat/chat_completion.rb', line 328

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

#modelString

The moderation model that produced this result.

Parameters:

  • value (String)

Returns:

  • (String)


334
# File 'lib/openai/models/chat/chat_completion.rb', line 334

required :model, String

#typeSymbol, :moderation_result

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

Parameters:

  • value (:moderation_result)

Returns:

  • (Symbol, :moderation_result)


341
# File 'lib/openai/models/chat/chat_completion.rb', line 341

required :type, const: :moderation_result

Instance Method Details

#to_hash{

Returns:

  • ({)


226
# File 'sig/openai/models/chat/chat_completion.rbs', line 226

def to_hash: -> {