moderation_api 2.19.0 → 2.21.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.
@@ -43,6 +43,22 @@ module ModerationAPI
43
43
  sig { params(channel: String).void }
44
44
  attr_writer :channel
45
45
 
46
+ # A recommendation from your own client-side flagging (e.g. a banned-IP list or a
47
+ # third-party tool). Feeds the rules engine and can escalate or override the
48
+ # recommended action. Does not change whether our analysis flagged the content.
49
+ sig do
50
+ returns(T.nilable(ModerationAPI::ContentSubmitParams::ClientAction))
51
+ end
52
+ attr_reader :client_action
53
+
54
+ sig do
55
+ params(
56
+ client_action:
57
+ ModerationAPI::ContentSubmitParams::ClientAction::OrHash
58
+ ).void
59
+ end
60
+ attr_writer :client_action
61
+
46
62
  # The unique ID of the content in your database.
47
63
  sig { returns(T.nilable(String)) }
48
64
  attr_reader :content_id
@@ -112,6 +128,7 @@ module ModerationAPI
112
128
  ModerationAPI::ContentSubmitParams::Policy::SelfHarm,
113
129
  ModerationAPI::ContentSubmitParams::Policy::Spam,
114
130
  ModerationAPI::ContentSubmitParams::Policy::LowQualityContent,
131
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection,
115
132
  ModerationAPI::ContentSubmitParams::Policy::SelfPromotion,
116
133
  ModerationAPI::ContentSubmitParams::Policy::Political,
117
134
  ModerationAPI::ContentSubmitParams::Policy::Religion,
@@ -152,6 +169,7 @@ module ModerationAPI
152
169
  ModerationAPI::ContentSubmitParams::Policy::SelfHarm::OrHash,
153
170
  ModerationAPI::ContentSubmitParams::Policy::Spam::OrHash,
154
171
  ModerationAPI::ContentSubmitParams::Policy::LowQualityContent::OrHash,
172
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::OrHash,
155
173
  ModerationAPI::ContentSubmitParams::Policy::SelfPromotion::OrHash,
156
174
  ModerationAPI::ContentSubmitParams::Policy::Political::OrHash,
157
175
  ModerationAPI::ContentSubmitParams::Policy::Religion::OrHash,
@@ -186,6 +204,8 @@ module ModerationAPI
186
204
  ),
187
205
  author_id: String,
188
206
  channel: String,
207
+ client_action:
208
+ ModerationAPI::ContentSubmitParams::ClientAction::OrHash,
189
209
  content_id: String,
190
210
  conversation_id: String,
191
211
  do_not_store: T::Boolean,
@@ -214,6 +234,7 @@ module ModerationAPI
214
234
  ModerationAPI::ContentSubmitParams::Policy::SelfHarm::OrHash,
215
235
  ModerationAPI::ContentSubmitParams::Policy::Spam::OrHash,
216
236
  ModerationAPI::ContentSubmitParams::Policy::LowQualityContent::OrHash,
237
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::OrHash,
217
238
  ModerationAPI::ContentSubmitParams::Policy::SelfPromotion::OrHash,
218
239
  ModerationAPI::ContentSubmitParams::Policy::Political::OrHash,
219
240
  ModerationAPI::ContentSubmitParams::Policy::Religion::OrHash,
@@ -236,6 +257,10 @@ module ModerationAPI
236
257
  # Provide a channel ID or key. Will use the project's default channel if not
237
258
  # provided.
238
259
  channel: nil,
260
+ # A recommendation from your own client-side flagging (e.g. a banned-IP list or a
261
+ # third-party tool). Feeds the rules engine and can escalate or override the
262
+ # recommended action. Does not change whether our analysis flagged the content.
263
+ client_action: nil,
239
264
  # The unique ID of the content in your database.
240
265
  content_id: nil,
241
266
  # For example the ID of a chat room or a post
@@ -268,6 +293,7 @@ module ModerationAPI
268
293
  ),
269
294
  author_id: String,
270
295
  channel: String,
296
+ client_action: ModerationAPI::ContentSubmitParams::ClientAction,
271
297
  content_id: String,
272
298
  conversation_id: String,
273
299
  do_not_store: T::Boolean,
@@ -296,6 +322,7 @@ module ModerationAPI
296
322
  ModerationAPI::ContentSubmitParams::Policy::SelfHarm,
297
323
  ModerationAPI::ContentSubmitParams::Policy::Spam,
298
324
  ModerationAPI::ContentSubmitParams::Policy::LowQualityContent,
325
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection,
299
326
  ModerationAPI::ContentSubmitParams::Policy::SelfPromotion,
300
327
  ModerationAPI::ContentSubmitParams::Policy::Political,
301
328
  ModerationAPI::ContentSubmitParams::Policy::Religion,
@@ -719,6 +746,174 @@ module ModerationAPI
719
746
  end
720
747
  end
721
748
 
749
+ class ClientAction < ModerationAPI::Internal::Type::BaseModel
750
+ OrHash =
751
+ T.type_alias do
752
+ T.any(
753
+ ModerationAPI::ContentSubmitParams::ClientAction,
754
+ ModerationAPI::Internal::AnyHash
755
+ )
756
+ end
757
+
758
+ # Your recommendation for the content: allow, review, or reject.
759
+ sig do
760
+ returns(
761
+ ModerationAPI::ContentSubmitParams::ClientAction::Action::OrSymbol
762
+ )
763
+ end
764
+ attr_accessor :action
765
+
766
+ # How your recommendation combines with ours. Defaults to 'escalate', which only
767
+ # applies it when stricter than ours; 'override' replaces ours outright.
768
+ sig do
769
+ returns(
770
+ T.nilable(
771
+ ModerationAPI::ContentSubmitParams::ClientAction::Behavior::OrSymbol
772
+ )
773
+ )
774
+ end
775
+ attr_reader :behavior
776
+
777
+ sig do
778
+ params(
779
+ behavior:
780
+ ModerationAPI::ContentSubmitParams::ClientAction::Behavior::OrSymbol
781
+ ).void
782
+ end
783
+ attr_writer :behavior
784
+
785
+ # A human-readable explanation for your recommendation.
786
+ sig { returns(T.nilable(String)) }
787
+ attr_reader :reason
788
+
789
+ sig { params(reason: String).void }
790
+ attr_writer :reason
791
+
792
+ # Where your recommendation came from, e.g. "banned-ip".
793
+ sig { returns(T.nilable(String)) }
794
+ attr_reader :source
795
+
796
+ sig { params(source: String).void }
797
+ attr_writer :source
798
+
799
+ # A recommendation from your own client-side flagging (e.g. a banned-IP list or a
800
+ # third-party tool). Feeds the rules engine and can escalate or override the
801
+ # recommended action. Does not change whether our analysis flagged the content.
802
+ sig do
803
+ params(
804
+ action:
805
+ ModerationAPI::ContentSubmitParams::ClientAction::Action::OrSymbol,
806
+ behavior:
807
+ ModerationAPI::ContentSubmitParams::ClientAction::Behavior::OrSymbol,
808
+ reason: String,
809
+ source: String
810
+ ).returns(T.attached_class)
811
+ end
812
+ def self.new(
813
+ # Your recommendation for the content: allow, review, or reject.
814
+ action:,
815
+ # How your recommendation combines with ours. Defaults to 'escalate', which only
816
+ # applies it when stricter than ours; 'override' replaces ours outright.
817
+ behavior: nil,
818
+ # A human-readable explanation for your recommendation.
819
+ reason: nil,
820
+ # Where your recommendation came from, e.g. "banned-ip".
821
+ source: nil
822
+ )
823
+ end
824
+
825
+ sig do
826
+ override.returns(
827
+ {
828
+ action:
829
+ ModerationAPI::ContentSubmitParams::ClientAction::Action::OrSymbol,
830
+ behavior:
831
+ ModerationAPI::ContentSubmitParams::ClientAction::Behavior::OrSymbol,
832
+ reason: String,
833
+ source: String
834
+ }
835
+ )
836
+ end
837
+ def to_hash
838
+ end
839
+
840
+ # Your recommendation for the content: allow, review, or reject.
841
+ module Action
842
+ extend ModerationAPI::Internal::Type::Enum
843
+
844
+ TaggedSymbol =
845
+ T.type_alias do
846
+ T.all(
847
+ Symbol,
848
+ ModerationAPI::ContentSubmitParams::ClientAction::Action
849
+ )
850
+ end
851
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
852
+
853
+ REVIEW =
854
+ T.let(
855
+ :review,
856
+ ModerationAPI::ContentSubmitParams::ClientAction::Action::TaggedSymbol
857
+ )
858
+ ALLOW =
859
+ T.let(
860
+ :allow,
861
+ ModerationAPI::ContentSubmitParams::ClientAction::Action::TaggedSymbol
862
+ )
863
+ REJECT =
864
+ T.let(
865
+ :reject,
866
+ ModerationAPI::ContentSubmitParams::ClientAction::Action::TaggedSymbol
867
+ )
868
+
869
+ sig do
870
+ override.returns(
871
+ T::Array[
872
+ ModerationAPI::ContentSubmitParams::ClientAction::Action::TaggedSymbol
873
+ ]
874
+ )
875
+ end
876
+ def self.values
877
+ end
878
+ end
879
+
880
+ # How your recommendation combines with ours. Defaults to 'escalate', which only
881
+ # applies it when stricter than ours; 'override' replaces ours outright.
882
+ module Behavior
883
+ extend ModerationAPI::Internal::Type::Enum
884
+
885
+ TaggedSymbol =
886
+ T.type_alias do
887
+ T.all(
888
+ Symbol,
889
+ ModerationAPI::ContentSubmitParams::ClientAction::Behavior
890
+ )
891
+ end
892
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
893
+
894
+ OVERRIDE =
895
+ T.let(
896
+ :override,
897
+ ModerationAPI::ContentSubmitParams::ClientAction::Behavior::TaggedSymbol
898
+ )
899
+ ESCALATE =
900
+ T.let(
901
+ :escalate,
902
+ ModerationAPI::ContentSubmitParams::ClientAction::Behavior::TaggedSymbol
903
+ )
904
+
905
+ sig do
906
+ override.returns(
907
+ T::Array[
908
+ ModerationAPI::ContentSubmitParams::ClientAction::Behavior::TaggedSymbol
909
+ ]
910
+ )
911
+ end
912
+ def self.values
913
+ end
914
+ end
915
+ end
916
+
722
917
  # The meta type of content being moderated
723
918
  module MetaType
724
919
  extend ModerationAPI::Internal::Type::Enum
@@ -805,6 +1000,7 @@ module ModerationAPI
805
1000
  ModerationAPI::ContentSubmitParams::Policy::SelfHarm,
806
1001
  ModerationAPI::ContentSubmitParams::Policy::Spam,
807
1002
  ModerationAPI::ContentSubmitParams::Policy::LowQualityContent,
1003
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection,
808
1004
  ModerationAPI::ContentSubmitParams::Policy::SelfPromotion,
809
1005
  ModerationAPI::ContentSubmitParams::Policy::Political,
810
1006
  ModerationAPI::ContentSubmitParams::Policy::Religion,
@@ -1561,6 +1757,129 @@ module ModerationAPI
1561
1757
  end
1562
1758
  end
1563
1759
 
1760
+ class FaceDetection < ModerationAPI::Internal::Type::BaseModel
1761
+ OrHash =
1762
+ T.type_alias do
1763
+ T.any(
1764
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection,
1765
+ ModerationAPI::Internal::AnyHash
1766
+ )
1767
+ end
1768
+
1769
+ sig { returns(Symbol) }
1770
+ attr_accessor :id
1771
+
1772
+ sig { returns(T::Boolean) }
1773
+ attr_accessor :flag
1774
+
1775
+ # Flag images that contain "at least" or "fewer than" the configured number of
1776
+ # faces. Defaults to at_least.
1777
+ sig do
1778
+ returns(
1779
+ T.nilable(
1780
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::Comparator::OrSymbol
1781
+ )
1782
+ )
1783
+ end
1784
+ attr_reader :comparator
1785
+
1786
+ sig do
1787
+ params(
1788
+ comparator:
1789
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::Comparator::OrSymbol
1790
+ ).void
1791
+ end
1792
+ attr_writer :comparator
1793
+
1794
+ # Number of faces the comparator applies to. Defaults to 1, so the default rule
1795
+ # flags any image containing a face.
1796
+ sig { returns(T.nilable(Integer)) }
1797
+ attr_reader :count
1798
+
1799
+ sig { params(count: Integer).void }
1800
+ attr_writer :count
1801
+
1802
+ sig { returns(T.nilable(Float)) }
1803
+ attr_reader :threshold
1804
+
1805
+ sig { params(threshold: Float).void }
1806
+ attr_writer :threshold
1807
+
1808
+ sig do
1809
+ params(
1810
+ flag: T::Boolean,
1811
+ comparator:
1812
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::Comparator::OrSymbol,
1813
+ count: Integer,
1814
+ threshold: Float,
1815
+ id: Symbol
1816
+ ).returns(T.attached_class)
1817
+ end
1818
+ def self.new(
1819
+ flag:,
1820
+ # Flag images that contain "at least" or "fewer than" the configured number of
1821
+ # faces. Defaults to at_least.
1822
+ comparator: nil,
1823
+ # Number of faces the comparator applies to. Defaults to 1, so the default rule
1824
+ # flags any image containing a face.
1825
+ count: nil,
1826
+ threshold: nil,
1827
+ id: :face_detection
1828
+ )
1829
+ end
1830
+
1831
+ sig do
1832
+ override.returns(
1833
+ {
1834
+ id: Symbol,
1835
+ flag: T::Boolean,
1836
+ comparator:
1837
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::Comparator::OrSymbol,
1838
+ count: Integer,
1839
+ threshold: Float
1840
+ }
1841
+ )
1842
+ end
1843
+ def to_hash
1844
+ end
1845
+
1846
+ # Flag images that contain "at least" or "fewer than" the configured number of
1847
+ # faces. Defaults to at_least.
1848
+ module Comparator
1849
+ extend ModerationAPI::Internal::Type::Enum
1850
+
1851
+ TaggedSymbol =
1852
+ T.type_alias do
1853
+ T.all(
1854
+ Symbol,
1855
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::Comparator
1856
+ )
1857
+ end
1858
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
1859
+
1860
+ AT_LEAST =
1861
+ T.let(
1862
+ :at_least,
1863
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::Comparator::TaggedSymbol
1864
+ )
1865
+ FEWER_THAN =
1866
+ T.let(
1867
+ :fewer_than,
1868
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::Comparator::TaggedSymbol
1869
+ )
1870
+
1871
+ sig do
1872
+ override.returns(
1873
+ T::Array[
1874
+ ModerationAPI::ContentSubmitParams::Policy::FaceDetection::Comparator::TaggedSymbol
1875
+ ]
1876
+ )
1877
+ end
1878
+ def self.values
1879
+ end
1880
+ end
1881
+ end
1882
+
1564
1883
  class SelfPromotion < ModerationAPI::Internal::Type::BaseModel
1565
1884
  OrHash =
1566
1885
  T.type_alias do
@@ -1093,6 +1093,14 @@ module ModerationAPI
1093
1093
  sig { returns(Symbol) }
1094
1094
  attr_accessor :type
1095
1095
 
1096
+ # Optional structured data produced by the policy. For face detection: { count,
1097
+ # faces: [{ confidence, gender, age }] }.
1098
+ sig { returns(T.nilable(T::Hash[Symbol, T.anything])) }
1099
+ attr_reader :data
1100
+
1101
+ sig { params(data: T::Hash[Symbol, T.anything]).void }
1102
+ attr_writer :data
1103
+
1096
1104
  # The keys of the flagged fields if submitting an object.
1097
1105
  sig { returns(T.nilable(T::Array[String])) }
1098
1106
  attr_reader :flagged_fields
@@ -1127,6 +1135,7 @@ module ModerationAPI
1127
1135
  id: String,
1128
1136
  flagged: T::Boolean,
1129
1137
  probability: Float,
1138
+ data: T::Hash[Symbol, T.anything],
1130
1139
  flagged_fields: T::Array[String],
1131
1140
  labels:
1132
1141
  T::Array[
@@ -1140,6 +1149,9 @@ module ModerationAPI
1140
1149
  id:,
1141
1150
  flagged:,
1142
1151
  probability:,
1152
+ # Optional structured data produced by the policy. For face detection: { count,
1153
+ # faces: [{ confidence, gender, age }] }.
1154
+ data: nil,
1143
1155
  # The keys of the flagged fields if submitting an object.
1144
1156
  flagged_fields: nil,
1145
1157
  labels: nil,
@@ -1154,6 +1166,7 @@ module ModerationAPI
1154
1166
  flagged: T::Boolean,
1155
1167
  probability: Float,
1156
1168
  type: Symbol,
1169
+ data: T::Hash[Symbol, T.anything],
1157
1170
  flagged_fields: T::Array[String],
1158
1171
  labels:
1159
1172
  T::Array[
@@ -1763,6 +1776,11 @@ module ModerationAPI
1763
1776
  :rule_fallback,
1764
1777
  ModerationAPI::Models::ContentSubmitResponse::Recommendation::ReasonCode::TaggedSymbol
1765
1778
  )
1779
+ CLIENT_OVERRIDE =
1780
+ T.let(
1781
+ :client_override,
1782
+ ModerationAPI::Models::ContentSubmitResponse::Recommendation::ReasonCode::TaggedSymbol
1783
+ )
1766
1784
 
1767
1785
  sig do
1768
1786
  override.returns(