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
|
@@ -180,6 +180,22 @@ module OpenAI
|
|
|
180
180
|
end
|
|
181
181
|
attr_accessor :modalities
|
|
182
182
|
|
|
183
|
+
# Configuration for running moderation on the request input and generated output.
|
|
184
|
+
sig do
|
|
185
|
+
returns(T.nilable(OpenAI::Chat::CompletionCreateParams::Moderation))
|
|
186
|
+
end
|
|
187
|
+
attr_reader :moderation
|
|
188
|
+
|
|
189
|
+
sig do
|
|
190
|
+
params(
|
|
191
|
+
moderation:
|
|
192
|
+
T.nilable(
|
|
193
|
+
OpenAI::Chat::CompletionCreateParams::Moderation::OrHash
|
|
194
|
+
)
|
|
195
|
+
).void
|
|
196
|
+
end
|
|
197
|
+
attr_writer :moderation
|
|
198
|
+
|
|
183
199
|
# How many chat completion choices to generate for each input message. Note that
|
|
184
200
|
# you will be charged based on the number of generated tokens across all of the
|
|
185
201
|
# choices. Keep `n` as `1` to minimize costs.
|
|
@@ -537,6 +553,10 @@ module OpenAI
|
|
|
537
553
|
OpenAI::Chat::CompletionCreateParams::Modality::OrSymbol
|
|
538
554
|
]
|
|
539
555
|
),
|
|
556
|
+
moderation:
|
|
557
|
+
T.nilable(
|
|
558
|
+
OpenAI::Chat::CompletionCreateParams::Moderation::OrHash
|
|
559
|
+
),
|
|
540
560
|
n: T.nilable(Integer),
|
|
541
561
|
parallel_tool_calls: T::Boolean,
|
|
542
562
|
prediction:
|
|
@@ -678,6 +698,8 @@ module OpenAI
|
|
|
678
698
|
#
|
|
679
699
|
# `["text", "audio"]`
|
|
680
700
|
modalities: nil,
|
|
701
|
+
# Configuration for running moderation on the request input and generated output.
|
|
702
|
+
moderation: nil,
|
|
681
703
|
# How many chat completion choices to generate for each input message. Note that
|
|
682
704
|
# you will be charged based on the number of generated tokens across all of the
|
|
683
705
|
# choices. Keep `n` as `1` to minimize costs.
|
|
@@ -861,6 +883,8 @@ module OpenAI
|
|
|
861
883
|
OpenAI::Chat::CompletionCreateParams::Modality::OrSymbol
|
|
862
884
|
]
|
|
863
885
|
),
|
|
886
|
+
moderation:
|
|
887
|
+
T.nilable(OpenAI::Chat::CompletionCreateParams::Moderation),
|
|
864
888
|
n: T.nilable(Integer),
|
|
865
889
|
parallel_tool_calls: T::Boolean,
|
|
866
890
|
prediction:
|
|
@@ -1118,6 +1142,34 @@ module OpenAI
|
|
|
1118
1142
|
end
|
|
1119
1143
|
end
|
|
1120
1144
|
|
|
1145
|
+
class Moderation < OpenAI::Internal::Type::BaseModel
|
|
1146
|
+
OrHash =
|
|
1147
|
+
T.type_alias do
|
|
1148
|
+
T.any(
|
|
1149
|
+
OpenAI::Chat::CompletionCreateParams::Moderation,
|
|
1150
|
+
OpenAI::Internal::AnyHash
|
|
1151
|
+
)
|
|
1152
|
+
end
|
|
1153
|
+
|
|
1154
|
+
# The moderation model to use for moderated completions, e.g.
|
|
1155
|
+
# 'omni-moderation-latest'.
|
|
1156
|
+
sig { returns(String) }
|
|
1157
|
+
attr_accessor :model
|
|
1158
|
+
|
|
1159
|
+
# Configuration for running moderation on the request input and generated output.
|
|
1160
|
+
sig { params(model: String).returns(T.attached_class) }
|
|
1161
|
+
def self.new(
|
|
1162
|
+
# The moderation model to use for moderated completions, e.g.
|
|
1163
|
+
# 'omni-moderation-latest'.
|
|
1164
|
+
model:
|
|
1165
|
+
)
|
|
1166
|
+
end
|
|
1167
|
+
|
|
1168
|
+
sig { override.returns({ model: String }) }
|
|
1169
|
+
def to_hash
|
|
1170
|
+
end
|
|
1171
|
+
end
|
|
1172
|
+
|
|
1121
1173
|
# The retention policy for the prompt cache. Set to `24h` to enable extended
|
|
1122
1174
|
# prompt caching, which keeps cached prefixes active for longer, up to a maximum
|
|
1123
1175
|
# of 24 hours.
|
|
@@ -170,6 +170,19 @@ module OpenAI
|
|
|
170
170
|
sig { returns(T.nilable(Integer)) }
|
|
171
171
|
attr_accessor :max_tool_calls
|
|
172
172
|
|
|
173
|
+
# Moderation results for the response input and output, if moderated completions
|
|
174
|
+
# were requested.
|
|
175
|
+
sig { returns(T.nilable(OpenAI::Responses::Response::Moderation)) }
|
|
176
|
+
attr_reader :moderation
|
|
177
|
+
|
|
178
|
+
sig do
|
|
179
|
+
params(
|
|
180
|
+
moderation:
|
|
181
|
+
T.nilable(OpenAI::Responses::Response::Moderation::OrHash)
|
|
182
|
+
).void
|
|
183
|
+
end
|
|
184
|
+
attr_writer :moderation
|
|
185
|
+
|
|
173
186
|
# The unique ID of the previous response to the model. Use this to create
|
|
174
187
|
# multi-turn conversations. Learn more about
|
|
175
188
|
# [conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
|
@@ -411,6 +424,8 @@ module OpenAI
|
|
|
411
424
|
T.nilable(OpenAI::Responses::Response::Conversation::OrHash),
|
|
412
425
|
max_output_tokens: T.nilable(Integer),
|
|
413
426
|
max_tool_calls: T.nilable(Integer),
|
|
427
|
+
moderation:
|
|
428
|
+
T.nilable(OpenAI::Responses::Response::Moderation::OrHash),
|
|
414
429
|
previous_response_id: T.nilable(String),
|
|
415
430
|
prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
|
|
416
431
|
prompt_cache_key: String,
|
|
@@ -523,6 +538,9 @@ module OpenAI
|
|
|
523
538
|
# individual tool. Any further attempts to call a tool by the model will be
|
|
524
539
|
# ignored.
|
|
525
540
|
max_tool_calls: nil,
|
|
541
|
+
# Moderation results for the response input and output, if moderated completions
|
|
542
|
+
# were requested.
|
|
543
|
+
moderation: nil,
|
|
526
544
|
# The unique ID of the previous response to the model. Use this to create
|
|
527
545
|
# multi-turn conversations. Learn more about
|
|
528
546
|
# [conversation state](https://platform.openai.com/docs/guides/conversation-state).
|
|
@@ -637,6 +655,7 @@ module OpenAI
|
|
|
637
655
|
T.nilable(OpenAI::Responses::Response::Conversation),
|
|
638
656
|
max_output_tokens: T.nilable(Integer),
|
|
639
657
|
max_tool_calls: T.nilable(Integer),
|
|
658
|
+
moderation: T.nilable(OpenAI::Responses::Response::Moderation),
|
|
640
659
|
previous_response_id: T.nilable(String),
|
|
641
660
|
prompt: T.nilable(OpenAI::Responses::ResponsePrompt),
|
|
642
661
|
prompt_cache_key: String,
|
|
@@ -841,6 +860,472 @@ module OpenAI
|
|
|
841
860
|
end
|
|
842
861
|
end
|
|
843
862
|
|
|
863
|
+
class Moderation < OpenAI::Internal::Type::BaseModel
|
|
864
|
+
OrHash =
|
|
865
|
+
T.type_alias do
|
|
866
|
+
T.any(
|
|
867
|
+
OpenAI::Responses::Response::Moderation,
|
|
868
|
+
OpenAI::Internal::AnyHash
|
|
869
|
+
)
|
|
870
|
+
end
|
|
871
|
+
|
|
872
|
+
# Moderation for the response input.
|
|
873
|
+
sig do
|
|
874
|
+
returns(OpenAI::Responses::Response::Moderation::Input::Variants)
|
|
875
|
+
end
|
|
876
|
+
attr_accessor :input
|
|
877
|
+
|
|
878
|
+
# Moderation for the response output.
|
|
879
|
+
sig do
|
|
880
|
+
returns(OpenAI::Responses::Response::Moderation::Output::Variants)
|
|
881
|
+
end
|
|
882
|
+
attr_accessor :output
|
|
883
|
+
|
|
884
|
+
# Moderation results for the response input and output, if moderated completions
|
|
885
|
+
# were requested.
|
|
886
|
+
sig do
|
|
887
|
+
params(
|
|
888
|
+
input:
|
|
889
|
+
T.any(
|
|
890
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult::OrHash,
|
|
891
|
+
OpenAI::Responses::Response::Moderation::Input::Error::OrHash
|
|
892
|
+
),
|
|
893
|
+
output:
|
|
894
|
+
T.any(
|
|
895
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult::OrHash,
|
|
896
|
+
OpenAI::Responses::Response::Moderation::Output::Error::OrHash
|
|
897
|
+
)
|
|
898
|
+
).returns(T.attached_class)
|
|
899
|
+
end
|
|
900
|
+
def self.new(
|
|
901
|
+
# Moderation for the response input.
|
|
902
|
+
input:,
|
|
903
|
+
# Moderation for the response output.
|
|
904
|
+
output:
|
|
905
|
+
)
|
|
906
|
+
end
|
|
907
|
+
|
|
908
|
+
sig do
|
|
909
|
+
override.returns(
|
|
910
|
+
{
|
|
911
|
+
input: OpenAI::Responses::Response::Moderation::Input::Variants,
|
|
912
|
+
output:
|
|
913
|
+
OpenAI::Responses::Response::Moderation::Output::Variants
|
|
914
|
+
}
|
|
915
|
+
)
|
|
916
|
+
end
|
|
917
|
+
def to_hash
|
|
918
|
+
end
|
|
919
|
+
|
|
920
|
+
# Moderation for the response input.
|
|
921
|
+
module Input
|
|
922
|
+
extend OpenAI::Internal::Type::Union
|
|
923
|
+
|
|
924
|
+
Variants =
|
|
925
|
+
T.type_alias do
|
|
926
|
+
T.any(
|
|
927
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult,
|
|
928
|
+
OpenAI::Responses::Response::Moderation::Input::Error
|
|
929
|
+
)
|
|
930
|
+
end
|
|
931
|
+
|
|
932
|
+
class ModerationResult < OpenAI::Internal::Type::BaseModel
|
|
933
|
+
OrHash =
|
|
934
|
+
T.type_alias do
|
|
935
|
+
T.any(
|
|
936
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult,
|
|
937
|
+
OpenAI::Internal::AnyHash
|
|
938
|
+
)
|
|
939
|
+
end
|
|
940
|
+
|
|
941
|
+
# A dictionary of moderation categories to booleans, True if the input is flagged
|
|
942
|
+
# under this category.
|
|
943
|
+
sig { returns(T::Hash[Symbol, T::Boolean]) }
|
|
944
|
+
attr_accessor :categories
|
|
945
|
+
|
|
946
|
+
# Which modalities of input are reflected by the score for each category.
|
|
947
|
+
sig do
|
|
948
|
+
returns(
|
|
949
|
+
T::Hash[
|
|
950
|
+
Symbol,
|
|
951
|
+
T::Array[
|
|
952
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
953
|
+
]
|
|
954
|
+
]
|
|
955
|
+
)
|
|
956
|
+
end
|
|
957
|
+
attr_accessor :category_applied_input_types
|
|
958
|
+
|
|
959
|
+
# A dictionary of moderation categories to scores.
|
|
960
|
+
sig { returns(T::Hash[Symbol, Float]) }
|
|
961
|
+
attr_accessor :category_scores
|
|
962
|
+
|
|
963
|
+
# A boolean indicating whether the content was flagged by any category.
|
|
964
|
+
sig { returns(T::Boolean) }
|
|
965
|
+
attr_accessor :flagged
|
|
966
|
+
|
|
967
|
+
# The moderation model that produced this result.
|
|
968
|
+
sig { returns(String) }
|
|
969
|
+
attr_accessor :model
|
|
970
|
+
|
|
971
|
+
# The object type, which was always `moderation_result` for successful moderation
|
|
972
|
+
# results.
|
|
973
|
+
sig { returns(Symbol) }
|
|
974
|
+
attr_accessor :type
|
|
975
|
+
|
|
976
|
+
# A moderation result produced for the response input or output.
|
|
977
|
+
sig do
|
|
978
|
+
params(
|
|
979
|
+
categories: T::Hash[Symbol, T::Boolean],
|
|
980
|
+
category_applied_input_types:
|
|
981
|
+
T::Hash[
|
|
982
|
+
Symbol,
|
|
983
|
+
T::Array[
|
|
984
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::OrSymbol
|
|
985
|
+
]
|
|
986
|
+
],
|
|
987
|
+
category_scores: T::Hash[Symbol, Float],
|
|
988
|
+
flagged: T::Boolean,
|
|
989
|
+
model: String,
|
|
990
|
+
type: Symbol
|
|
991
|
+
).returns(T.attached_class)
|
|
992
|
+
end
|
|
993
|
+
def self.new(
|
|
994
|
+
# A dictionary of moderation categories to booleans, True if the input is flagged
|
|
995
|
+
# under this category.
|
|
996
|
+
categories:,
|
|
997
|
+
# Which modalities of input are reflected by the score for each category.
|
|
998
|
+
category_applied_input_types:,
|
|
999
|
+
# A dictionary of moderation categories to scores.
|
|
1000
|
+
category_scores:,
|
|
1001
|
+
# A boolean indicating whether the content was flagged by any category.
|
|
1002
|
+
flagged:,
|
|
1003
|
+
# The moderation model that produced this result.
|
|
1004
|
+
model:,
|
|
1005
|
+
# The object type, which was always `moderation_result` for successful moderation
|
|
1006
|
+
# results.
|
|
1007
|
+
type: :moderation_result
|
|
1008
|
+
)
|
|
1009
|
+
end
|
|
1010
|
+
|
|
1011
|
+
sig do
|
|
1012
|
+
override.returns(
|
|
1013
|
+
{
|
|
1014
|
+
categories: T::Hash[Symbol, T::Boolean],
|
|
1015
|
+
category_applied_input_types:
|
|
1016
|
+
T::Hash[
|
|
1017
|
+
Symbol,
|
|
1018
|
+
T::Array[
|
|
1019
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1020
|
+
]
|
|
1021
|
+
],
|
|
1022
|
+
category_scores: T::Hash[Symbol, Float],
|
|
1023
|
+
flagged: T::Boolean,
|
|
1024
|
+
model: String,
|
|
1025
|
+
type: Symbol
|
|
1026
|
+
}
|
|
1027
|
+
)
|
|
1028
|
+
end
|
|
1029
|
+
def to_hash
|
|
1030
|
+
end
|
|
1031
|
+
|
|
1032
|
+
module CategoryAppliedInputType
|
|
1033
|
+
extend OpenAI::Internal::Type::Enum
|
|
1034
|
+
|
|
1035
|
+
TaggedSymbol =
|
|
1036
|
+
T.type_alias do
|
|
1037
|
+
T.all(
|
|
1038
|
+
Symbol,
|
|
1039
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType
|
|
1040
|
+
)
|
|
1041
|
+
end
|
|
1042
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
1043
|
+
|
|
1044
|
+
TEXT =
|
|
1045
|
+
T.let(
|
|
1046
|
+
:text,
|
|
1047
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1048
|
+
)
|
|
1049
|
+
IMAGE =
|
|
1050
|
+
T.let(
|
|
1051
|
+
:image,
|
|
1052
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1053
|
+
)
|
|
1054
|
+
|
|
1055
|
+
sig do
|
|
1056
|
+
override.returns(
|
|
1057
|
+
T::Array[
|
|
1058
|
+
OpenAI::Responses::Response::Moderation::Input::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1059
|
+
]
|
|
1060
|
+
)
|
|
1061
|
+
end
|
|
1062
|
+
def self.values
|
|
1063
|
+
end
|
|
1064
|
+
end
|
|
1065
|
+
end
|
|
1066
|
+
|
|
1067
|
+
class Error < OpenAI::Internal::Type::BaseModel
|
|
1068
|
+
OrHash =
|
|
1069
|
+
T.type_alias do
|
|
1070
|
+
T.any(
|
|
1071
|
+
OpenAI::Responses::Response::Moderation::Input::Error,
|
|
1072
|
+
OpenAI::Internal::AnyHash
|
|
1073
|
+
)
|
|
1074
|
+
end
|
|
1075
|
+
|
|
1076
|
+
# The error code.
|
|
1077
|
+
sig { returns(String) }
|
|
1078
|
+
attr_accessor :code
|
|
1079
|
+
|
|
1080
|
+
# The error message.
|
|
1081
|
+
sig { returns(String) }
|
|
1082
|
+
attr_accessor :message
|
|
1083
|
+
|
|
1084
|
+
# The object type, which was always `error` for moderation failures.
|
|
1085
|
+
sig { returns(Symbol) }
|
|
1086
|
+
attr_accessor :type
|
|
1087
|
+
|
|
1088
|
+
# An error produced while attempting moderation for the response input or output.
|
|
1089
|
+
sig do
|
|
1090
|
+
params(code: String, message: String, type: Symbol).returns(
|
|
1091
|
+
T.attached_class
|
|
1092
|
+
)
|
|
1093
|
+
end
|
|
1094
|
+
def self.new(
|
|
1095
|
+
# The error code.
|
|
1096
|
+
code:,
|
|
1097
|
+
# The error message.
|
|
1098
|
+
message:,
|
|
1099
|
+
# The object type, which was always `error` for moderation failures.
|
|
1100
|
+
type: :error
|
|
1101
|
+
)
|
|
1102
|
+
end
|
|
1103
|
+
|
|
1104
|
+
sig do
|
|
1105
|
+
override.returns(
|
|
1106
|
+
{ code: String, message: String, type: Symbol }
|
|
1107
|
+
)
|
|
1108
|
+
end
|
|
1109
|
+
def to_hash
|
|
1110
|
+
end
|
|
1111
|
+
end
|
|
1112
|
+
|
|
1113
|
+
sig do
|
|
1114
|
+
override.returns(
|
|
1115
|
+
T::Array[
|
|
1116
|
+
OpenAI::Responses::Response::Moderation::Input::Variants
|
|
1117
|
+
]
|
|
1118
|
+
)
|
|
1119
|
+
end
|
|
1120
|
+
def self.variants
|
|
1121
|
+
end
|
|
1122
|
+
end
|
|
1123
|
+
|
|
1124
|
+
# Moderation for the response output.
|
|
1125
|
+
module Output
|
|
1126
|
+
extend OpenAI::Internal::Type::Union
|
|
1127
|
+
|
|
1128
|
+
Variants =
|
|
1129
|
+
T.type_alias do
|
|
1130
|
+
T.any(
|
|
1131
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult,
|
|
1132
|
+
OpenAI::Responses::Response::Moderation::Output::Error
|
|
1133
|
+
)
|
|
1134
|
+
end
|
|
1135
|
+
|
|
1136
|
+
class ModerationResult < OpenAI::Internal::Type::BaseModel
|
|
1137
|
+
OrHash =
|
|
1138
|
+
T.type_alias do
|
|
1139
|
+
T.any(
|
|
1140
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult,
|
|
1141
|
+
OpenAI::Internal::AnyHash
|
|
1142
|
+
)
|
|
1143
|
+
end
|
|
1144
|
+
|
|
1145
|
+
# A dictionary of moderation categories to booleans, True if the input is flagged
|
|
1146
|
+
# under this category.
|
|
1147
|
+
sig { returns(T::Hash[Symbol, T::Boolean]) }
|
|
1148
|
+
attr_accessor :categories
|
|
1149
|
+
|
|
1150
|
+
# Which modalities of input are reflected by the score for each category.
|
|
1151
|
+
sig do
|
|
1152
|
+
returns(
|
|
1153
|
+
T::Hash[
|
|
1154
|
+
Symbol,
|
|
1155
|
+
T::Array[
|
|
1156
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1157
|
+
]
|
|
1158
|
+
]
|
|
1159
|
+
)
|
|
1160
|
+
end
|
|
1161
|
+
attr_accessor :category_applied_input_types
|
|
1162
|
+
|
|
1163
|
+
# A dictionary of moderation categories to scores.
|
|
1164
|
+
sig { returns(T::Hash[Symbol, Float]) }
|
|
1165
|
+
attr_accessor :category_scores
|
|
1166
|
+
|
|
1167
|
+
# A boolean indicating whether the content was flagged by any category.
|
|
1168
|
+
sig { returns(T::Boolean) }
|
|
1169
|
+
attr_accessor :flagged
|
|
1170
|
+
|
|
1171
|
+
# The moderation model that produced this result.
|
|
1172
|
+
sig { returns(String) }
|
|
1173
|
+
attr_accessor :model
|
|
1174
|
+
|
|
1175
|
+
# The object type, which was always `moderation_result` for successful moderation
|
|
1176
|
+
# results.
|
|
1177
|
+
sig { returns(Symbol) }
|
|
1178
|
+
attr_accessor :type
|
|
1179
|
+
|
|
1180
|
+
# A moderation result produced for the response input or output.
|
|
1181
|
+
sig do
|
|
1182
|
+
params(
|
|
1183
|
+
categories: T::Hash[Symbol, T::Boolean],
|
|
1184
|
+
category_applied_input_types:
|
|
1185
|
+
T::Hash[
|
|
1186
|
+
Symbol,
|
|
1187
|
+
T::Array[
|
|
1188
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::OrSymbol
|
|
1189
|
+
]
|
|
1190
|
+
],
|
|
1191
|
+
category_scores: T::Hash[Symbol, Float],
|
|
1192
|
+
flagged: T::Boolean,
|
|
1193
|
+
model: String,
|
|
1194
|
+
type: Symbol
|
|
1195
|
+
).returns(T.attached_class)
|
|
1196
|
+
end
|
|
1197
|
+
def self.new(
|
|
1198
|
+
# A dictionary of moderation categories to booleans, True if the input is flagged
|
|
1199
|
+
# under this category.
|
|
1200
|
+
categories:,
|
|
1201
|
+
# Which modalities of input are reflected by the score for each category.
|
|
1202
|
+
category_applied_input_types:,
|
|
1203
|
+
# A dictionary of moderation categories to scores.
|
|
1204
|
+
category_scores:,
|
|
1205
|
+
# A boolean indicating whether the content was flagged by any category.
|
|
1206
|
+
flagged:,
|
|
1207
|
+
# The moderation model that produced this result.
|
|
1208
|
+
model:,
|
|
1209
|
+
# The object type, which was always `moderation_result` for successful moderation
|
|
1210
|
+
# results.
|
|
1211
|
+
type: :moderation_result
|
|
1212
|
+
)
|
|
1213
|
+
end
|
|
1214
|
+
|
|
1215
|
+
sig do
|
|
1216
|
+
override.returns(
|
|
1217
|
+
{
|
|
1218
|
+
categories: T::Hash[Symbol, T::Boolean],
|
|
1219
|
+
category_applied_input_types:
|
|
1220
|
+
T::Hash[
|
|
1221
|
+
Symbol,
|
|
1222
|
+
T::Array[
|
|
1223
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1224
|
+
]
|
|
1225
|
+
],
|
|
1226
|
+
category_scores: T::Hash[Symbol, Float],
|
|
1227
|
+
flagged: T::Boolean,
|
|
1228
|
+
model: String,
|
|
1229
|
+
type: Symbol
|
|
1230
|
+
}
|
|
1231
|
+
)
|
|
1232
|
+
end
|
|
1233
|
+
def to_hash
|
|
1234
|
+
end
|
|
1235
|
+
|
|
1236
|
+
module CategoryAppliedInputType
|
|
1237
|
+
extend OpenAI::Internal::Type::Enum
|
|
1238
|
+
|
|
1239
|
+
TaggedSymbol =
|
|
1240
|
+
T.type_alias do
|
|
1241
|
+
T.all(
|
|
1242
|
+
Symbol,
|
|
1243
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType
|
|
1244
|
+
)
|
|
1245
|
+
end
|
|
1246
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
1247
|
+
|
|
1248
|
+
TEXT =
|
|
1249
|
+
T.let(
|
|
1250
|
+
:text,
|
|
1251
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1252
|
+
)
|
|
1253
|
+
IMAGE =
|
|
1254
|
+
T.let(
|
|
1255
|
+
:image,
|
|
1256
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1257
|
+
)
|
|
1258
|
+
|
|
1259
|
+
sig do
|
|
1260
|
+
override.returns(
|
|
1261
|
+
T::Array[
|
|
1262
|
+
OpenAI::Responses::Response::Moderation::Output::ModerationResult::CategoryAppliedInputType::TaggedSymbol
|
|
1263
|
+
]
|
|
1264
|
+
)
|
|
1265
|
+
end
|
|
1266
|
+
def self.values
|
|
1267
|
+
end
|
|
1268
|
+
end
|
|
1269
|
+
end
|
|
1270
|
+
|
|
1271
|
+
class Error < OpenAI::Internal::Type::BaseModel
|
|
1272
|
+
OrHash =
|
|
1273
|
+
T.type_alias do
|
|
1274
|
+
T.any(
|
|
1275
|
+
OpenAI::Responses::Response::Moderation::Output::Error,
|
|
1276
|
+
OpenAI::Internal::AnyHash
|
|
1277
|
+
)
|
|
1278
|
+
end
|
|
1279
|
+
|
|
1280
|
+
# The error code.
|
|
1281
|
+
sig { returns(String) }
|
|
1282
|
+
attr_accessor :code
|
|
1283
|
+
|
|
1284
|
+
# The error message.
|
|
1285
|
+
sig { returns(String) }
|
|
1286
|
+
attr_accessor :message
|
|
1287
|
+
|
|
1288
|
+
# The object type, which was always `error` for moderation failures.
|
|
1289
|
+
sig { returns(Symbol) }
|
|
1290
|
+
attr_accessor :type
|
|
1291
|
+
|
|
1292
|
+
# An error produced while attempting moderation for the response input or output.
|
|
1293
|
+
sig do
|
|
1294
|
+
params(code: String, message: String, type: Symbol).returns(
|
|
1295
|
+
T.attached_class
|
|
1296
|
+
)
|
|
1297
|
+
end
|
|
1298
|
+
def self.new(
|
|
1299
|
+
# The error code.
|
|
1300
|
+
code:,
|
|
1301
|
+
# The error message.
|
|
1302
|
+
message:,
|
|
1303
|
+
# The object type, which was always `error` for moderation failures.
|
|
1304
|
+
type: :error
|
|
1305
|
+
)
|
|
1306
|
+
end
|
|
1307
|
+
|
|
1308
|
+
sig do
|
|
1309
|
+
override.returns(
|
|
1310
|
+
{ code: String, message: String, type: Symbol }
|
|
1311
|
+
)
|
|
1312
|
+
end
|
|
1313
|
+
def to_hash
|
|
1314
|
+
end
|
|
1315
|
+
end
|
|
1316
|
+
|
|
1317
|
+
sig do
|
|
1318
|
+
override.returns(
|
|
1319
|
+
T::Array[
|
|
1320
|
+
OpenAI::Responses::Response::Moderation::Output::Variants
|
|
1321
|
+
]
|
|
1322
|
+
)
|
|
1323
|
+
end
|
|
1324
|
+
def self.variants
|
|
1325
|
+
end
|
|
1326
|
+
end
|
|
1327
|
+
end
|
|
1328
|
+
|
|
844
1329
|
# The retention policy for the prompt cache. Set to `24h` to enable extended
|
|
845
1330
|
# prompt caching, which keeps cached prefixes active for longer, up to a maximum
|
|
846
1331
|
# of 24 hours.
|
|
@@ -153,6 +153,24 @@ module OpenAI
|
|
|
153
153
|
end
|
|
154
154
|
attr_writer :model
|
|
155
155
|
|
|
156
|
+
# Configuration for running moderation on the input and output of this response.
|
|
157
|
+
sig do
|
|
158
|
+
returns(
|
|
159
|
+
T.nilable(OpenAI::Responses::ResponseCreateParams::Moderation)
|
|
160
|
+
)
|
|
161
|
+
end
|
|
162
|
+
attr_reader :moderation
|
|
163
|
+
|
|
164
|
+
sig do
|
|
165
|
+
params(
|
|
166
|
+
moderation:
|
|
167
|
+
T.nilable(
|
|
168
|
+
OpenAI::Responses::ResponseCreateParams::Moderation::OrHash
|
|
169
|
+
)
|
|
170
|
+
).void
|
|
171
|
+
end
|
|
172
|
+
attr_writer :moderation
|
|
173
|
+
|
|
156
174
|
# Whether to allow the model to run tool calls in parallel.
|
|
157
175
|
sig { returns(T.nilable(T::Boolean)) }
|
|
158
176
|
attr_accessor :parallel_tool_calls
|
|
@@ -483,6 +501,10 @@ module OpenAI
|
|
|
483
501
|
OpenAI::ChatModel::OrSymbol,
|
|
484
502
|
OpenAI::ResponsesModel::ResponsesOnlyModel::OrSymbol
|
|
485
503
|
),
|
|
504
|
+
moderation:
|
|
505
|
+
T.nilable(
|
|
506
|
+
OpenAI::Responses::ResponseCreateParams::Moderation::OrHash
|
|
507
|
+
),
|
|
486
508
|
parallel_tool_calls: T.nilable(T::Boolean),
|
|
487
509
|
previous_response_id: T.nilable(String),
|
|
488
510
|
prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
|
|
@@ -613,6 +635,8 @@ module OpenAI
|
|
|
613
635
|
# [model guide](https://platform.openai.com/docs/models) to browse and compare
|
|
614
636
|
# available models.
|
|
615
637
|
model: nil,
|
|
638
|
+
# Configuration for running moderation on the input and output of this response.
|
|
639
|
+
moderation: nil,
|
|
616
640
|
# Whether to allow the model to run tool calls in parallel.
|
|
617
641
|
parallel_tool_calls: nil,
|
|
618
642
|
# The unique ID of the previous response to the model. Use this to create
|
|
@@ -765,6 +789,8 @@ module OpenAI
|
|
|
765
789
|
OpenAI::ChatModel::OrSymbol,
|
|
766
790
|
OpenAI::ResponsesModel::ResponsesOnlyModel::OrSymbol
|
|
767
791
|
),
|
|
792
|
+
moderation:
|
|
793
|
+
T.nilable(OpenAI::Responses::ResponseCreateParams::Moderation),
|
|
768
794
|
parallel_tool_calls: T.nilable(T::Boolean),
|
|
769
795
|
previous_response_id: T.nilable(String),
|
|
770
796
|
prompt: T.nilable(OpenAI::Responses::ResponsePrompt),
|
|
@@ -922,6 +948,34 @@ module OpenAI
|
|
|
922
948
|
end
|
|
923
949
|
end
|
|
924
950
|
|
|
951
|
+
class Moderation < OpenAI::Internal::Type::BaseModel
|
|
952
|
+
OrHash =
|
|
953
|
+
T.type_alias do
|
|
954
|
+
T.any(
|
|
955
|
+
OpenAI::Responses::ResponseCreateParams::Moderation,
|
|
956
|
+
OpenAI::Internal::AnyHash
|
|
957
|
+
)
|
|
958
|
+
end
|
|
959
|
+
|
|
960
|
+
# The moderation model to use for moderated completions, e.g.
|
|
961
|
+
# 'omni-moderation-latest'.
|
|
962
|
+
sig { returns(String) }
|
|
963
|
+
attr_accessor :model
|
|
964
|
+
|
|
965
|
+
# Configuration for running moderation on the input and output of this response.
|
|
966
|
+
sig { params(model: String).returns(T.attached_class) }
|
|
967
|
+
def self.new(
|
|
968
|
+
# The moderation model to use for moderated completions, e.g.
|
|
969
|
+
# 'omni-moderation-latest'.
|
|
970
|
+
model:
|
|
971
|
+
)
|
|
972
|
+
end
|
|
973
|
+
|
|
974
|
+
sig { override.returns({ model: String }) }
|
|
975
|
+
def to_hash
|
|
976
|
+
end
|
|
977
|
+
end
|
|
978
|
+
|
|
925
979
|
# The retention policy for the prompt cache. Set to `24h` to enable extended
|
|
926
980
|
# prompt caching, which keeps cached prefixes active for longer, up to a maximum
|
|
927
981
|
# of 24 hours.
|