openai 0.65.0 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/openai/models/chat/chat_completion.rb +341 -3
- data/lib/openai/models/chat/chat_completion_chunk.rb +341 -1
- data/lib/openai/models/chat/completion_create_params.rb +26 -1
- data/lib/openai/models/responses/response.rb +275 -1
- data/lib/openai/models/responses/response_create_params.rb +26 -1
- data/lib/openai/models/responses/responses_client_event.rb +27 -1
- data/lib/openai/resources/chat/completions.rb +6 -2
- data/lib/openai/resources/responses.rb +6 -2
- data/lib/openai/version.rb +1 -1
- data/rbi/openai/models/chat/chat_completion.rbi +620 -3
- data/rbi/openai/models/chat/chat_completion_chunk.rbi +621 -0
- data/rbi/openai/models/chat/completion_create_params.rbi +52 -0
- data/rbi/openai/models/responses/response.rbi +485 -0
- data/rbi/openai/models/responses/response_create_params.rbi +54 -0
- data/rbi/openai/models/responses/responses_client_event.rbi +54 -0
- data/rbi/openai/resources/chat/completions.rbi +12 -0
- data/rbi/openai/resources/responses.rbi +12 -0
- data/sig/openai/models/chat/chat_completion.rbs +243 -0
- data/sig/openai/models/chat/chat_completion_chunk.rbs +243 -0
- data/sig/openai/models/chat/completion_create_params.rbs +15 -0
- data/sig/openai/models/responses/response.rbs +189 -0
- data/sig/openai/models/responses/response_create_params.rbs +15 -0
- data/sig/openai/models/responses/responses_client_event.rbs +15 -0
- data/sig/openai/resources/chat/completions.rbs +2 -0
- data/sig/openai/resources/responses.rbs +2 -0
- metadata +2 -2
|
@@ -32,6 +32,19 @@ module OpenAI
|
|
|
32
32
|
sig { returns(Symbol) }
|
|
33
33
|
attr_accessor :object
|
|
34
34
|
|
|
35
|
+
# Moderation results for the request input and generated output, if moderated
|
|
36
|
+
# completions were requested.
|
|
37
|
+
sig { returns(T.nilable(OpenAI::Chat::ChatCompletion::Moderation)) }
|
|
38
|
+
attr_reader :moderation
|
|
39
|
+
|
|
40
|
+
sig do
|
|
41
|
+
params(
|
|
42
|
+
moderation:
|
|
43
|
+
T.nilable(OpenAI::Chat::ChatCompletion::Moderation::OrHash)
|
|
44
|
+
).void
|
|
45
|
+
end
|
|
46
|
+
attr_writer :moderation
|
|
47
|
+
|
|
35
48
|
# Specifies the processing type used for serving the request.
|
|
36
49
|
#
|
|
37
50
|
# - If set to 'auto', then the request will be processed with the service tier
|
|
@@ -80,6 +93,8 @@ module OpenAI
|
|
|
80
93
|
choices: T::Array[OpenAI::Chat::ChatCompletion::Choice::OrHash],
|
|
81
94
|
created: Integer,
|
|
82
95
|
model: String,
|
|
96
|
+
moderation:
|
|
97
|
+
T.nilable(OpenAI::Chat::ChatCompletion::Moderation::OrHash),
|
|
83
98
|
service_tier:
|
|
84
99
|
T.nilable(OpenAI::Chat::ChatCompletion::ServiceTier::OrSymbol),
|
|
85
100
|
system_fingerprint: String,
|
|
@@ -97,6 +112,9 @@ module OpenAI
|
|
|
97
112
|
created:,
|
|
98
113
|
# The model used for the chat completion.
|
|
99
114
|
model:,
|
|
115
|
+
# Moderation results for the request input and generated output, if moderated
|
|
116
|
+
# completions were requested.
|
|
117
|
+
moderation: nil,
|
|
100
118
|
# Specifies the processing type used for serving the request.
|
|
101
119
|
#
|
|
102
120
|
# - If set to 'auto', then the request will be processed with the service tier
|
|
@@ -134,6 +152,7 @@ module OpenAI
|
|
|
134
152
|
created: Integer,
|
|
135
153
|
model: String,
|
|
136
154
|
object: Symbol,
|
|
155
|
+
moderation: T.nilable(OpenAI::Chat::ChatCompletion::Moderation),
|
|
137
156
|
service_tier:
|
|
138
157
|
T.nilable(
|
|
139
158
|
OpenAI::Chat::ChatCompletion::ServiceTier::TaggedSymbol
|
|
@@ -160,7 +179,8 @@ module OpenAI
|
|
|
160
179
|
# number of tokens specified in the request was reached, `content_filter` if
|
|
161
180
|
# content was omitted due to a flag from our content filters, `tool_calls` if the
|
|
162
181
|
# model called a tool, or `function_call` (deprecated) if the model called a
|
|
163
|
-
# function.
|
|
182
|
+
# function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html)
|
|
183
|
+
# for more.
|
|
164
184
|
sig do
|
|
165
185
|
returns(
|
|
166
186
|
OpenAI::Chat::ChatCompletion::Choice::FinishReason::TaggedSymbol
|
|
@@ -215,7 +235,8 @@ module OpenAI
|
|
|
215
235
|
# number of tokens specified in the request was reached, `content_filter` if
|
|
216
236
|
# content was omitted due to a flag from our content filters, `tool_calls` if the
|
|
217
237
|
# model called a tool, or `function_call` (deprecated) if the model called a
|
|
218
|
-
# function.
|
|
238
|
+
# function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html)
|
|
239
|
+
# for more.
|
|
219
240
|
finish_reason:,
|
|
220
241
|
# The index of the choice in the list of choices.
|
|
221
242
|
index:,
|
|
@@ -246,7 +267,8 @@ module OpenAI
|
|
|
246
267
|
# number of tokens specified in the request was reached, `content_filter` if
|
|
247
268
|
# content was omitted due to a flag from our content filters, `tool_calls` if the
|
|
248
269
|
# model called a tool, or `function_call` (deprecated) if the model called a
|
|
249
|
-
# function.
|
|
270
|
+
# function. Read the [Model Spec](https://model-spec.openai.com/2025-12-18.html)
|
|
271
|
+
# for more.
|
|
250
272
|
module FinishReason
|
|
251
273
|
extend OpenAI::Internal::Type::Enum
|
|
252
274
|
|
|
@@ -361,6 +383,601 @@ module OpenAI
|
|
|
361
383
|
end
|
|
362
384
|
end
|
|
363
385
|
|
|
386
|
+
class Moderation < OpenAI::Internal::Type::BaseModel
|
|
387
|
+
OrHash =
|
|
388
|
+
T.type_alias do
|
|
389
|
+
T.any(
|
|
390
|
+
OpenAI::Chat::ChatCompletion::Moderation,
|
|
391
|
+
OpenAI::Internal::AnyHash
|
|
392
|
+
)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Moderation for the request input.
|
|
396
|
+
sig do
|
|
397
|
+
returns(OpenAI::Chat::ChatCompletion::Moderation::Input::Variants)
|
|
398
|
+
end
|
|
399
|
+
attr_accessor :input
|
|
400
|
+
|
|
401
|
+
# Moderation for the generated output.
|
|
402
|
+
sig do
|
|
403
|
+
returns(OpenAI::Chat::ChatCompletion::Moderation::Output::Variants)
|
|
404
|
+
end
|
|
405
|
+
attr_accessor :output
|
|
406
|
+
|
|
407
|
+
# Moderation results for the request input and generated output, if moderated
|
|
408
|
+
# completions were requested.
|
|
409
|
+
sig do
|
|
410
|
+
params(
|
|
411
|
+
input:
|
|
412
|
+
T.any(
|
|
413
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::OrHash,
|
|
414
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::Error::OrHash
|
|
415
|
+
),
|
|
416
|
+
output:
|
|
417
|
+
T.any(
|
|
418
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::OrHash,
|
|
419
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::Error::OrHash
|
|
420
|
+
)
|
|
421
|
+
).returns(T.attached_class)
|
|
422
|
+
end
|
|
423
|
+
def self.new(
|
|
424
|
+
# Moderation for the request input.
|
|
425
|
+
input:,
|
|
426
|
+
# Moderation for the generated output.
|
|
427
|
+
output:
|
|
428
|
+
)
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
sig do
|
|
432
|
+
override.returns(
|
|
433
|
+
{
|
|
434
|
+
input:
|
|
435
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::Variants,
|
|
436
|
+
output:
|
|
437
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::Variants
|
|
438
|
+
}
|
|
439
|
+
)
|
|
440
|
+
end
|
|
441
|
+
def to_hash
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# Moderation for the request input.
|
|
445
|
+
module Input
|
|
446
|
+
extend OpenAI::Internal::Type::Union
|
|
447
|
+
|
|
448
|
+
Variants =
|
|
449
|
+
T.type_alias do
|
|
450
|
+
T.any(
|
|
451
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults,
|
|
452
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::Error
|
|
453
|
+
)
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
class ModerationResults < OpenAI::Internal::Type::BaseModel
|
|
457
|
+
OrHash =
|
|
458
|
+
T.type_alias do
|
|
459
|
+
T.any(
|
|
460
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults,
|
|
461
|
+
OpenAI::Internal::AnyHash
|
|
462
|
+
)
|
|
463
|
+
end
|
|
464
|
+
|
|
465
|
+
# The moderation model used to generate the results.
|
|
466
|
+
sig { returns(String) }
|
|
467
|
+
attr_accessor :model
|
|
468
|
+
|
|
469
|
+
# A list of moderation results.
|
|
470
|
+
sig do
|
|
471
|
+
returns(
|
|
472
|
+
T::Array[
|
|
473
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result
|
|
474
|
+
]
|
|
475
|
+
)
|
|
476
|
+
end
|
|
477
|
+
attr_accessor :results
|
|
478
|
+
|
|
479
|
+
# The object type, which is always `moderation_results`.
|
|
480
|
+
sig { returns(Symbol) }
|
|
481
|
+
attr_accessor :type
|
|
482
|
+
|
|
483
|
+
# Successful moderation results for the request input or generated output.
|
|
484
|
+
sig do
|
|
485
|
+
params(
|
|
486
|
+
model: String,
|
|
487
|
+
results:
|
|
488
|
+
T::Array[
|
|
489
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::OrHash
|
|
490
|
+
],
|
|
491
|
+
type: Symbol
|
|
492
|
+
).returns(T.attached_class)
|
|
493
|
+
end
|
|
494
|
+
def self.new(
|
|
495
|
+
# The moderation model used to generate the results.
|
|
496
|
+
model:,
|
|
497
|
+
# A list of moderation results.
|
|
498
|
+
results:,
|
|
499
|
+
# The object type, which is always `moderation_results`.
|
|
500
|
+
type: :moderation_results
|
|
501
|
+
)
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
sig do
|
|
505
|
+
override.returns(
|
|
506
|
+
{
|
|
507
|
+
model: String,
|
|
508
|
+
results:
|
|
509
|
+
T::Array[
|
|
510
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result
|
|
511
|
+
],
|
|
512
|
+
type: Symbol
|
|
513
|
+
}
|
|
514
|
+
)
|
|
515
|
+
end
|
|
516
|
+
def to_hash
|
|
517
|
+
end
|
|
518
|
+
|
|
519
|
+
class Result < OpenAI::Internal::Type::BaseModel
|
|
520
|
+
OrHash =
|
|
521
|
+
T.type_alias do
|
|
522
|
+
T.any(
|
|
523
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result,
|
|
524
|
+
OpenAI::Internal::AnyHash
|
|
525
|
+
)
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
# A dictionary of moderation categories to booleans, True if the input is flagged
|
|
529
|
+
# under this category.
|
|
530
|
+
sig { returns(T::Hash[Symbol, T::Boolean]) }
|
|
531
|
+
attr_accessor :categories
|
|
532
|
+
|
|
533
|
+
# Which modalities of input are reflected by the score for each category.
|
|
534
|
+
sig do
|
|
535
|
+
returns(
|
|
536
|
+
T::Hash[
|
|
537
|
+
Symbol,
|
|
538
|
+
T::Array[
|
|
539
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
540
|
+
]
|
|
541
|
+
]
|
|
542
|
+
)
|
|
543
|
+
end
|
|
544
|
+
attr_accessor :category_applied_input_types
|
|
545
|
+
|
|
546
|
+
# A dictionary of moderation categories to scores.
|
|
547
|
+
sig { returns(T::Hash[Symbol, Float]) }
|
|
548
|
+
attr_accessor :category_scores
|
|
549
|
+
|
|
550
|
+
# A boolean indicating whether the content was flagged by any category.
|
|
551
|
+
sig { returns(T::Boolean) }
|
|
552
|
+
attr_accessor :flagged
|
|
553
|
+
|
|
554
|
+
# The moderation model that produced this result.
|
|
555
|
+
sig { returns(String) }
|
|
556
|
+
attr_accessor :model
|
|
557
|
+
|
|
558
|
+
# The object type, which was always `moderation_result` for successful moderation
|
|
559
|
+
# results.
|
|
560
|
+
sig { returns(Symbol) }
|
|
561
|
+
attr_accessor :type
|
|
562
|
+
|
|
563
|
+
# A moderation result produced for the response input or output.
|
|
564
|
+
sig do
|
|
565
|
+
params(
|
|
566
|
+
categories: T::Hash[Symbol, T::Boolean],
|
|
567
|
+
category_applied_input_types:
|
|
568
|
+
T::Hash[
|
|
569
|
+
Symbol,
|
|
570
|
+
T::Array[
|
|
571
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType::OrSymbol
|
|
572
|
+
]
|
|
573
|
+
],
|
|
574
|
+
category_scores: T::Hash[Symbol, Float],
|
|
575
|
+
flagged: T::Boolean,
|
|
576
|
+
model: String,
|
|
577
|
+
type: Symbol
|
|
578
|
+
).returns(T.attached_class)
|
|
579
|
+
end
|
|
580
|
+
def self.new(
|
|
581
|
+
# A dictionary of moderation categories to booleans, True if the input is flagged
|
|
582
|
+
# under this category.
|
|
583
|
+
categories:,
|
|
584
|
+
# Which modalities of input are reflected by the score for each category.
|
|
585
|
+
category_applied_input_types:,
|
|
586
|
+
# A dictionary of moderation categories to scores.
|
|
587
|
+
category_scores:,
|
|
588
|
+
# A boolean indicating whether the content was flagged by any category.
|
|
589
|
+
flagged:,
|
|
590
|
+
# The moderation model that produced this result.
|
|
591
|
+
model:,
|
|
592
|
+
# The object type, which was always `moderation_result` for successful moderation
|
|
593
|
+
# results.
|
|
594
|
+
type: :moderation_result
|
|
595
|
+
)
|
|
596
|
+
end
|
|
597
|
+
|
|
598
|
+
sig do
|
|
599
|
+
override.returns(
|
|
600
|
+
{
|
|
601
|
+
categories: T::Hash[Symbol, T::Boolean],
|
|
602
|
+
category_applied_input_types:
|
|
603
|
+
T::Hash[
|
|
604
|
+
Symbol,
|
|
605
|
+
T::Array[
|
|
606
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
607
|
+
]
|
|
608
|
+
],
|
|
609
|
+
category_scores: T::Hash[Symbol, Float],
|
|
610
|
+
flagged: T::Boolean,
|
|
611
|
+
model: String,
|
|
612
|
+
type: Symbol
|
|
613
|
+
}
|
|
614
|
+
)
|
|
615
|
+
end
|
|
616
|
+
def to_hash
|
|
617
|
+
end
|
|
618
|
+
|
|
619
|
+
module CategoryAppliedInputType
|
|
620
|
+
extend OpenAI::Internal::Type::Enum
|
|
621
|
+
|
|
622
|
+
TaggedSymbol =
|
|
623
|
+
T.type_alias do
|
|
624
|
+
T.all(
|
|
625
|
+
Symbol,
|
|
626
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType
|
|
627
|
+
)
|
|
628
|
+
end
|
|
629
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
630
|
+
|
|
631
|
+
TEXT =
|
|
632
|
+
T.let(
|
|
633
|
+
:text,
|
|
634
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
635
|
+
)
|
|
636
|
+
IMAGE =
|
|
637
|
+
T.let(
|
|
638
|
+
:image,
|
|
639
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
640
|
+
)
|
|
641
|
+
|
|
642
|
+
sig do
|
|
643
|
+
override.returns(
|
|
644
|
+
T::Array[
|
|
645
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
646
|
+
]
|
|
647
|
+
)
|
|
648
|
+
end
|
|
649
|
+
def self.values
|
|
650
|
+
end
|
|
651
|
+
end
|
|
652
|
+
end
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
class Error < OpenAI::Internal::Type::BaseModel
|
|
656
|
+
OrHash =
|
|
657
|
+
T.type_alias do
|
|
658
|
+
T.any(
|
|
659
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::Error,
|
|
660
|
+
OpenAI::Internal::AnyHash
|
|
661
|
+
)
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
# The error code.
|
|
665
|
+
sig { returns(String) }
|
|
666
|
+
attr_accessor :code
|
|
667
|
+
|
|
668
|
+
# The error message.
|
|
669
|
+
sig { returns(String) }
|
|
670
|
+
attr_accessor :message
|
|
671
|
+
|
|
672
|
+
# The object type, which is always `error`.
|
|
673
|
+
sig { returns(Symbol) }
|
|
674
|
+
attr_accessor :type
|
|
675
|
+
|
|
676
|
+
# An error produced while attempting moderation.
|
|
677
|
+
sig do
|
|
678
|
+
params(code: String, message: String, type: Symbol).returns(
|
|
679
|
+
T.attached_class
|
|
680
|
+
)
|
|
681
|
+
end
|
|
682
|
+
def self.new(
|
|
683
|
+
# The error code.
|
|
684
|
+
code:,
|
|
685
|
+
# The error message.
|
|
686
|
+
message:,
|
|
687
|
+
# The object type, which is always `error`.
|
|
688
|
+
type: :error
|
|
689
|
+
)
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
sig do
|
|
693
|
+
override.returns(
|
|
694
|
+
{ code: String, message: String, type: Symbol }
|
|
695
|
+
)
|
|
696
|
+
end
|
|
697
|
+
def to_hash
|
|
698
|
+
end
|
|
699
|
+
end
|
|
700
|
+
|
|
701
|
+
sig do
|
|
702
|
+
override.returns(
|
|
703
|
+
T::Array[
|
|
704
|
+
OpenAI::Chat::ChatCompletion::Moderation::Input::Variants
|
|
705
|
+
]
|
|
706
|
+
)
|
|
707
|
+
end
|
|
708
|
+
def self.variants
|
|
709
|
+
end
|
|
710
|
+
end
|
|
711
|
+
|
|
712
|
+
# Moderation for the generated output.
|
|
713
|
+
module Output
|
|
714
|
+
extend OpenAI::Internal::Type::Union
|
|
715
|
+
|
|
716
|
+
Variants =
|
|
717
|
+
T.type_alias do
|
|
718
|
+
T.any(
|
|
719
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults,
|
|
720
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::Error
|
|
721
|
+
)
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
class ModerationResults < OpenAI::Internal::Type::BaseModel
|
|
725
|
+
OrHash =
|
|
726
|
+
T.type_alias do
|
|
727
|
+
T.any(
|
|
728
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults,
|
|
729
|
+
OpenAI::Internal::AnyHash
|
|
730
|
+
)
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
# The moderation model used to generate the results.
|
|
734
|
+
sig { returns(String) }
|
|
735
|
+
attr_accessor :model
|
|
736
|
+
|
|
737
|
+
# A list of moderation results.
|
|
738
|
+
sig do
|
|
739
|
+
returns(
|
|
740
|
+
T::Array[
|
|
741
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result
|
|
742
|
+
]
|
|
743
|
+
)
|
|
744
|
+
end
|
|
745
|
+
attr_accessor :results
|
|
746
|
+
|
|
747
|
+
# The object type, which is always `moderation_results`.
|
|
748
|
+
sig { returns(Symbol) }
|
|
749
|
+
attr_accessor :type
|
|
750
|
+
|
|
751
|
+
# Successful moderation results for the request input or generated output.
|
|
752
|
+
sig do
|
|
753
|
+
params(
|
|
754
|
+
model: String,
|
|
755
|
+
results:
|
|
756
|
+
T::Array[
|
|
757
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::OrHash
|
|
758
|
+
],
|
|
759
|
+
type: Symbol
|
|
760
|
+
).returns(T.attached_class)
|
|
761
|
+
end
|
|
762
|
+
def self.new(
|
|
763
|
+
# The moderation model used to generate the results.
|
|
764
|
+
model:,
|
|
765
|
+
# A list of moderation results.
|
|
766
|
+
results:,
|
|
767
|
+
# The object type, which is always `moderation_results`.
|
|
768
|
+
type: :moderation_results
|
|
769
|
+
)
|
|
770
|
+
end
|
|
771
|
+
|
|
772
|
+
sig do
|
|
773
|
+
override.returns(
|
|
774
|
+
{
|
|
775
|
+
model: String,
|
|
776
|
+
results:
|
|
777
|
+
T::Array[
|
|
778
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result
|
|
779
|
+
],
|
|
780
|
+
type: Symbol
|
|
781
|
+
}
|
|
782
|
+
)
|
|
783
|
+
end
|
|
784
|
+
def to_hash
|
|
785
|
+
end
|
|
786
|
+
|
|
787
|
+
class Result < OpenAI::Internal::Type::BaseModel
|
|
788
|
+
OrHash =
|
|
789
|
+
T.type_alias do
|
|
790
|
+
T.any(
|
|
791
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result,
|
|
792
|
+
OpenAI::Internal::AnyHash
|
|
793
|
+
)
|
|
794
|
+
end
|
|
795
|
+
|
|
796
|
+
# A dictionary of moderation categories to booleans, True if the input is flagged
|
|
797
|
+
# under this category.
|
|
798
|
+
sig { returns(T::Hash[Symbol, T::Boolean]) }
|
|
799
|
+
attr_accessor :categories
|
|
800
|
+
|
|
801
|
+
# Which modalities of input are reflected by the score for each category.
|
|
802
|
+
sig do
|
|
803
|
+
returns(
|
|
804
|
+
T::Hash[
|
|
805
|
+
Symbol,
|
|
806
|
+
T::Array[
|
|
807
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
808
|
+
]
|
|
809
|
+
]
|
|
810
|
+
)
|
|
811
|
+
end
|
|
812
|
+
attr_accessor :category_applied_input_types
|
|
813
|
+
|
|
814
|
+
# A dictionary of moderation categories to scores.
|
|
815
|
+
sig { returns(T::Hash[Symbol, Float]) }
|
|
816
|
+
attr_accessor :category_scores
|
|
817
|
+
|
|
818
|
+
# A boolean indicating whether the content was flagged by any category.
|
|
819
|
+
sig { returns(T::Boolean) }
|
|
820
|
+
attr_accessor :flagged
|
|
821
|
+
|
|
822
|
+
# The moderation model that produced this result.
|
|
823
|
+
sig { returns(String) }
|
|
824
|
+
attr_accessor :model
|
|
825
|
+
|
|
826
|
+
# The object type, which was always `moderation_result` for successful moderation
|
|
827
|
+
# results.
|
|
828
|
+
sig { returns(Symbol) }
|
|
829
|
+
attr_accessor :type
|
|
830
|
+
|
|
831
|
+
# A moderation result produced for the response input or output.
|
|
832
|
+
sig do
|
|
833
|
+
params(
|
|
834
|
+
categories: T::Hash[Symbol, T::Boolean],
|
|
835
|
+
category_applied_input_types:
|
|
836
|
+
T::Hash[
|
|
837
|
+
Symbol,
|
|
838
|
+
T::Array[
|
|
839
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType::OrSymbol
|
|
840
|
+
]
|
|
841
|
+
],
|
|
842
|
+
category_scores: T::Hash[Symbol, Float],
|
|
843
|
+
flagged: T::Boolean,
|
|
844
|
+
model: String,
|
|
845
|
+
type: Symbol
|
|
846
|
+
).returns(T.attached_class)
|
|
847
|
+
end
|
|
848
|
+
def self.new(
|
|
849
|
+
# A dictionary of moderation categories to booleans, True if the input is flagged
|
|
850
|
+
# under this category.
|
|
851
|
+
categories:,
|
|
852
|
+
# Which modalities of input are reflected by the score for each category.
|
|
853
|
+
category_applied_input_types:,
|
|
854
|
+
# A dictionary of moderation categories to scores.
|
|
855
|
+
category_scores:,
|
|
856
|
+
# A boolean indicating whether the content was flagged by any category.
|
|
857
|
+
flagged:,
|
|
858
|
+
# The moderation model that produced this result.
|
|
859
|
+
model:,
|
|
860
|
+
# The object type, which was always `moderation_result` for successful moderation
|
|
861
|
+
# results.
|
|
862
|
+
type: :moderation_result
|
|
863
|
+
)
|
|
864
|
+
end
|
|
865
|
+
|
|
866
|
+
sig do
|
|
867
|
+
override.returns(
|
|
868
|
+
{
|
|
869
|
+
categories: T::Hash[Symbol, T::Boolean],
|
|
870
|
+
category_applied_input_types:
|
|
871
|
+
T::Hash[
|
|
872
|
+
Symbol,
|
|
873
|
+
T::Array[
|
|
874
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
875
|
+
]
|
|
876
|
+
],
|
|
877
|
+
category_scores: T::Hash[Symbol, Float],
|
|
878
|
+
flagged: T::Boolean,
|
|
879
|
+
model: String,
|
|
880
|
+
type: Symbol
|
|
881
|
+
}
|
|
882
|
+
)
|
|
883
|
+
end
|
|
884
|
+
def to_hash
|
|
885
|
+
end
|
|
886
|
+
|
|
887
|
+
module CategoryAppliedInputType
|
|
888
|
+
extend OpenAI::Internal::Type::Enum
|
|
889
|
+
|
|
890
|
+
TaggedSymbol =
|
|
891
|
+
T.type_alias do
|
|
892
|
+
T.all(
|
|
893
|
+
Symbol,
|
|
894
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType
|
|
895
|
+
)
|
|
896
|
+
end
|
|
897
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
898
|
+
|
|
899
|
+
TEXT =
|
|
900
|
+
T.let(
|
|
901
|
+
:text,
|
|
902
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
903
|
+
)
|
|
904
|
+
IMAGE =
|
|
905
|
+
T.let(
|
|
906
|
+
:image,
|
|
907
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
908
|
+
)
|
|
909
|
+
|
|
910
|
+
sig do
|
|
911
|
+
override.returns(
|
|
912
|
+
T::Array[
|
|
913
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::ModerationResults::Result::CategoryAppliedInputType::TaggedSymbol
|
|
914
|
+
]
|
|
915
|
+
)
|
|
916
|
+
end
|
|
917
|
+
def self.values
|
|
918
|
+
end
|
|
919
|
+
end
|
|
920
|
+
end
|
|
921
|
+
end
|
|
922
|
+
|
|
923
|
+
class Error < OpenAI::Internal::Type::BaseModel
|
|
924
|
+
OrHash =
|
|
925
|
+
T.type_alias do
|
|
926
|
+
T.any(
|
|
927
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::Error,
|
|
928
|
+
OpenAI::Internal::AnyHash
|
|
929
|
+
)
|
|
930
|
+
end
|
|
931
|
+
|
|
932
|
+
# The error code.
|
|
933
|
+
sig { returns(String) }
|
|
934
|
+
attr_accessor :code
|
|
935
|
+
|
|
936
|
+
# The error message.
|
|
937
|
+
sig { returns(String) }
|
|
938
|
+
attr_accessor :message
|
|
939
|
+
|
|
940
|
+
# The object type, which is always `error`.
|
|
941
|
+
sig { returns(Symbol) }
|
|
942
|
+
attr_accessor :type
|
|
943
|
+
|
|
944
|
+
# An error produced while attempting moderation.
|
|
945
|
+
sig do
|
|
946
|
+
params(code: String, message: String, type: Symbol).returns(
|
|
947
|
+
T.attached_class
|
|
948
|
+
)
|
|
949
|
+
end
|
|
950
|
+
def self.new(
|
|
951
|
+
# The error code.
|
|
952
|
+
code:,
|
|
953
|
+
# The error message.
|
|
954
|
+
message:,
|
|
955
|
+
# The object type, which is always `error`.
|
|
956
|
+
type: :error
|
|
957
|
+
)
|
|
958
|
+
end
|
|
959
|
+
|
|
960
|
+
sig do
|
|
961
|
+
override.returns(
|
|
962
|
+
{ code: String, message: String, type: Symbol }
|
|
963
|
+
)
|
|
964
|
+
end
|
|
965
|
+
def to_hash
|
|
966
|
+
end
|
|
967
|
+
end
|
|
968
|
+
|
|
969
|
+
sig do
|
|
970
|
+
override.returns(
|
|
971
|
+
T::Array[
|
|
972
|
+
OpenAI::Chat::ChatCompletion::Moderation::Output::Variants
|
|
973
|
+
]
|
|
974
|
+
)
|
|
975
|
+
end
|
|
976
|
+
def self.variants
|
|
977
|
+
end
|
|
978
|
+
end
|
|
979
|
+
end
|
|
980
|
+
|
|
364
981
|
# Specifies the processing type used for serving the request.
|
|
365
982
|
#
|
|
366
983
|
# - If set to 'auto', then the request will be processed with the service tier
|