safetykit 0.49.0 → 0.51.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 +16 -0
- data/README.md +1 -1
- data/lib/safety_kit/client.rb +6 -0
- data/lib/safety_kit/models/content_create_params.rb +63 -0
- data/lib/safety_kit/models/content_create_response.rb +158 -0
- data/lib/safety_kit/models/stream_add_frame_params.rb +11 -1
- data/lib/safety_kit/models.rb +2 -0
- data/lib/safety_kit/resources/content.rb +52 -0
- data/lib/safety_kit/resources/streams.rb +3 -1
- data/lib/safety_kit/version.rb +1 -1
- data/lib/safety_kit.rb +3 -0
- data/rbi/safety_kit/client.rbi +5 -0
- data/rbi/safety_kit/models/content_create_params.rbi +99 -0
- data/rbi/safety_kit/models/content_create_response.rbi +278 -0
- data/rbi/safety_kit/models/stream_add_frame_params.rbi +15 -0
- data/rbi/safety_kit/models.rbi +2 -0
- data/rbi/safety_kit/resources/content.rbi +49 -0
- data/rbi/safety_kit/resources/streams.rbi +5 -0
- data/sig/safety_kit/client.rbs +2 -0
- data/sig/safety_kit/models/content_create_params.rbs +54 -0
- data/sig/safety_kit/models/content_create_response.rbs +104 -0
- data/sig/safety_kit/models/stream_add_frame_params.rbs +8 -1
- data/sig/safety_kit/models.rbs +2 -0
- data/sig/safety_kit/resources/content.rbs +16 -0
- data/sig/safety_kit/resources/streams.rbs +1 -0
- metadata +11 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: edca5667de202b072736d856befde1d6dc5c05159172501817845236aef204f0
|
|
4
|
+
data.tar.gz: 80ab0c4d50b502d7bc63be3358cb7ce94f3075a1d30b7f2716a3e33ca9c90aeb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 47729951a4064258d19e89c45cbbcdbda4e4a9a1ef7672114047c0bf7cc974b8298f5221c8c1d18e8285d9749f8cc1789900d07895c29df45fcf0048ff917b6d
|
|
7
|
+
data.tar.gz: 3eb38d4ff7ed1cfae936e0bddf738063776594954a2e8c36ba68ca37caf528e364234636c9202eb3e6b029e7de827d74c1a8f43d1c7dc159f69cd6e889e8c654
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.51.0 (2026-08-05)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.50.0...v0.51.0](https://github.com/GetSafetyKit/safetykit-ruby/compare/v0.50.0...v0.51.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** api update ([3a57f4e](https://github.com/GetSafetyKit/safetykit-ruby/commit/3a57f4e95d35ddb799c71c06db72ccedbd171560))
|
|
10
|
+
|
|
11
|
+
## 0.50.0 (2026-08-01)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v0.49.0...v0.50.0](https://github.com/GetSafetyKit/safetykit-ruby/compare/v0.49.0...v0.50.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** api update ([0f2676b](https://github.com/GetSafetyKit/safetykit-ruby/commit/0f2676b4f1b89391e398e1ae101f70de5bd07772))
|
|
18
|
+
|
|
3
19
|
## 0.49.0 (2026-07-31)
|
|
4
20
|
|
|
5
21
|
Full Changelog: [v0.48.0...v0.49.0](https://github.com/GetSafetyKit/safetykit-ruby/compare/v0.48.0...v0.49.0)
|
data/README.md
CHANGED
data/lib/safety_kit/client.rb
CHANGED
|
@@ -42,6 +42,11 @@ module SafetyKit
|
|
|
42
42
|
# @return [SafetyKit::Resources::Async]
|
|
43
43
|
attr_reader :async
|
|
44
44
|
|
|
45
|
+
# Classify user-authored text and images synchronously and receive a decision in
|
|
46
|
+
# the response.
|
|
47
|
+
# @return [SafetyKit::Resources::Content]
|
|
48
|
+
attr_reader :content
|
|
49
|
+
|
|
45
50
|
# Submit end-user deletion requests. Accepted requests are processed
|
|
46
51
|
# asynchronously.
|
|
47
52
|
# @return [SafetyKit::Resources::DeletionRequests]
|
|
@@ -128,6 +133,7 @@ module SafetyKit
|
|
|
128
133
|
@agent_decisions = SafetyKit::Resources::AgentDecisions.new(client: self)
|
|
129
134
|
@access_tokens = SafetyKit::Resources::AccessTokens.new(client: self)
|
|
130
135
|
@async = SafetyKit::Resources::Async.new(client: self)
|
|
136
|
+
@content = SafetyKit::Resources::Content.new(client: self)
|
|
131
137
|
@deletion_requests = SafetyKit::Resources::DeletionRequests.new(client: self)
|
|
132
138
|
@client_sessions = SafetyKit::Resources::ClientSessions.new(client: self)
|
|
133
139
|
@beta = SafetyKit::Resources::Beta.new(client: self)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SafetyKit
|
|
4
|
+
module Models
|
|
5
|
+
# @see SafetyKit::Resources::Content#create
|
|
6
|
+
class ContentCreateParams < SafetyKit::Internal::Type::BaseModel
|
|
7
|
+
extend SafetyKit::Internal::Type::RequestParameters::Converter
|
|
8
|
+
include SafetyKit::Internal::Type::RequestParameters
|
|
9
|
+
|
|
10
|
+
# @!attribute entity_id
|
|
11
|
+
# Your stable identifier for the entity this content belongs to, such as a user,
|
|
12
|
+
# listing, or message thread.
|
|
13
|
+
#
|
|
14
|
+
# @return [String]
|
|
15
|
+
required :entity_id, String
|
|
16
|
+
|
|
17
|
+
# @!attribute content_id
|
|
18
|
+
# Your identifier for this piece of content — the same content_id you send on
|
|
19
|
+
# /v1/events. When provided, the event this call records deduplicates against the
|
|
20
|
+
# same upload posted through the events API, so sending both never double-counts
|
|
21
|
+
# the content.
|
|
22
|
+
#
|
|
23
|
+
# @return [String, nil]
|
|
24
|
+
optional :content_id, String
|
|
25
|
+
|
|
26
|
+
# @!attribute images
|
|
27
|
+
# Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
|
|
28
|
+
# most 4 images. The full request body must stay under 6MB, which allows roughly
|
|
29
|
+
# 4.4MB of raw image bytes after base64 inflation.
|
|
30
|
+
#
|
|
31
|
+
# @return [Array<String>, nil]
|
|
32
|
+
optional :images, SafetyKit::Internal::Type::ArrayOf[String]
|
|
33
|
+
|
|
34
|
+
# @!attribute metadata
|
|
35
|
+
# Additional product context for this content. At most 8KB when serialized.
|
|
36
|
+
#
|
|
37
|
+
# @return [Hash{Symbol=>Object, nil}, nil]
|
|
38
|
+
optional :metadata, SafetyKit::Internal::Type::HashOf[SafetyKit::Internal::Type::Unknown, nil?: true]
|
|
39
|
+
|
|
40
|
+
# @!attribute text
|
|
41
|
+
# User-authored text to classify. At most 20000 characters.
|
|
42
|
+
#
|
|
43
|
+
# @return [String, nil]
|
|
44
|
+
optional :text, String
|
|
45
|
+
|
|
46
|
+
# @!method initialize(entity_id:, content_id: nil, images: nil, metadata: nil, text: nil, request_options: {})
|
|
47
|
+
# Some parameter documentations has been truncated, see
|
|
48
|
+
# {SafetyKit::Models::ContentCreateParams} for more details.
|
|
49
|
+
#
|
|
50
|
+
# @param entity_id [String] Your stable identifier for the entity this content belongs to, such as a user, l
|
|
51
|
+
#
|
|
52
|
+
# @param content_id [String] Your identifier for this piece of content — the same content_id you send on /v1/
|
|
53
|
+
#
|
|
54
|
+
# @param images [Array<String>] Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
|
|
55
|
+
#
|
|
56
|
+
# @param metadata [Hash{Symbol=>Object, nil}] Additional product context for this content. At most 8KB when serialized.
|
|
57
|
+
#
|
|
58
|
+
# @param text [String] User-authored text to classify. At most 20000 characters.
|
|
59
|
+
#
|
|
60
|
+
# @param request_options [SafetyKit::RequestOptions, Hash{Symbol=>Object}]
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SafetyKit
|
|
4
|
+
module Models
|
|
5
|
+
# @see SafetyKit::Resources::Content#create
|
|
6
|
+
class ContentCreateResponse < SafetyKit::Internal::Type::BaseModel
|
|
7
|
+
# @!attribute content_id
|
|
8
|
+
# SafetyKit identifier for the classified content.
|
|
9
|
+
#
|
|
10
|
+
# @return [String]
|
|
11
|
+
required :content_id, String
|
|
12
|
+
|
|
13
|
+
# @!attribute decision
|
|
14
|
+
# SafetyKit's decision for the submitted content: approve (no violation found),
|
|
15
|
+
# reject (violating), or review (needs human review).
|
|
16
|
+
#
|
|
17
|
+
# @return [Symbol, SafetyKit::Models::ContentCreateResponse::Decision]
|
|
18
|
+
required :decision, enum: -> { SafetyKit::Models::ContentCreateResponse::Decision }
|
|
19
|
+
|
|
20
|
+
# @!attribute entity_id
|
|
21
|
+
# The entity_id from the request.
|
|
22
|
+
#
|
|
23
|
+
# @return [String]
|
|
24
|
+
required :entity_id, String
|
|
25
|
+
|
|
26
|
+
# @!attribute escalation
|
|
27
|
+
# Escalation outcome for this request: none (the request never entered the
|
|
28
|
+
# escalation band), completed (the escalated verdict is reflected in decision), or
|
|
29
|
+
# timed_out (escalation did not finish in budget, so decision is a provisional
|
|
30
|
+
# review).
|
|
31
|
+
#
|
|
32
|
+
# @return [Symbol, SafetyKit::Models::ContentCreateResponse::Escalation]
|
|
33
|
+
required :escalation, enum: -> { SafetyKit::Models::ContentCreateResponse::Escalation }
|
|
34
|
+
|
|
35
|
+
# @!attribute mirrored
|
|
36
|
+
# Whether SafetyKit mirrored the submitted content for later review.
|
|
37
|
+
#
|
|
38
|
+
# @return [Boolean]
|
|
39
|
+
required :mirrored, SafetyKit::Internal::Type::Boolean
|
|
40
|
+
|
|
41
|
+
# @!attribute reference_set_matches
|
|
42
|
+
# Reference set matches found for the submitted content.
|
|
43
|
+
#
|
|
44
|
+
# @return [Array<SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch>]
|
|
45
|
+
required :reference_set_matches,
|
|
46
|
+
-> { SafetyKit::Internal::Type::ArrayOf[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch] }
|
|
47
|
+
|
|
48
|
+
# @!attribute scores
|
|
49
|
+
# Classifier scores produced for the submitted content.
|
|
50
|
+
#
|
|
51
|
+
# @return [Array<SafetyKit::Models::ContentCreateResponse::Score>]
|
|
52
|
+
required :scores,
|
|
53
|
+
-> { SafetyKit::Internal::Type::ArrayOf[SafetyKit::Models::ContentCreateResponse::Score] }
|
|
54
|
+
|
|
55
|
+
# @!method initialize(content_id:, decision:, entity_id:, escalation:, mirrored:, reference_set_matches:, scores:)
|
|
56
|
+
# Some parameter documentations has been truncated, see
|
|
57
|
+
# {SafetyKit::Models::ContentCreateResponse} for more details.
|
|
58
|
+
#
|
|
59
|
+
# Synchronous classification result for the submitted content.
|
|
60
|
+
#
|
|
61
|
+
# @param content_id [String] SafetyKit identifier for the classified content.
|
|
62
|
+
#
|
|
63
|
+
# @param decision [Symbol, SafetyKit::Models::ContentCreateResponse::Decision] SafetyKit's decision for the submitted content: approve (no violation found), re
|
|
64
|
+
#
|
|
65
|
+
# @param entity_id [String] The entity_id from the request.
|
|
66
|
+
#
|
|
67
|
+
# @param escalation [Symbol, SafetyKit::Models::ContentCreateResponse::Escalation] Escalation outcome for this request: none (the request never entered the escalat
|
|
68
|
+
#
|
|
69
|
+
# @param mirrored [Boolean] Whether SafetyKit mirrored the submitted content for later review.
|
|
70
|
+
#
|
|
71
|
+
# @param reference_set_matches [Array<SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch>] Reference set matches found for the submitted content.
|
|
72
|
+
#
|
|
73
|
+
# @param scores [Array<SafetyKit::Models::ContentCreateResponse::Score>] Classifier scores produced for the submitted content.
|
|
74
|
+
|
|
75
|
+
# SafetyKit's decision for the submitted content: approve (no violation found),
|
|
76
|
+
# reject (violating), or review (needs human review).
|
|
77
|
+
#
|
|
78
|
+
# @see SafetyKit::Models::ContentCreateResponse#decision
|
|
79
|
+
module Decision
|
|
80
|
+
extend SafetyKit::Internal::Type::Enum
|
|
81
|
+
|
|
82
|
+
APPROVE = :approve
|
|
83
|
+
REJECT = :reject
|
|
84
|
+
REVIEW = :review
|
|
85
|
+
|
|
86
|
+
# @!method self.values
|
|
87
|
+
# @return [Array<Symbol>]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Escalation outcome for this request: none (the request never entered the
|
|
91
|
+
# escalation band), completed (the escalated verdict is reflected in decision), or
|
|
92
|
+
# timed_out (escalation did not finish in budget, so decision is a provisional
|
|
93
|
+
# review).
|
|
94
|
+
#
|
|
95
|
+
# @see SafetyKit::Models::ContentCreateResponse#escalation
|
|
96
|
+
module Escalation
|
|
97
|
+
extend SafetyKit::Internal::Type::Enum
|
|
98
|
+
|
|
99
|
+
NONE = :none
|
|
100
|
+
COMPLETED = :completed
|
|
101
|
+
TIMED_OUT = :timed_out
|
|
102
|
+
|
|
103
|
+
# @!method self.values
|
|
104
|
+
# @return [Array<Symbol>]
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
class ReferenceSetMatch < SafetyKit::Internal::Type::BaseModel
|
|
108
|
+
# @!attribute set_id
|
|
109
|
+
# Identifier of the matched reference set.
|
|
110
|
+
#
|
|
111
|
+
# @return [String]
|
|
112
|
+
required :set_id, String
|
|
113
|
+
|
|
114
|
+
# @!attribute similarity
|
|
115
|
+
# Similarity between the submitted content and the matched reference set entry.
|
|
116
|
+
#
|
|
117
|
+
# @return [Float]
|
|
118
|
+
required :similarity, Float
|
|
119
|
+
|
|
120
|
+
# @!method initialize(set_id:, similarity:)
|
|
121
|
+
# Reference set match found for the submitted content.
|
|
122
|
+
#
|
|
123
|
+
# @param set_id [String] Identifier of the matched reference set.
|
|
124
|
+
#
|
|
125
|
+
# @param similarity [Float] Similarity between the submitted content and the matched reference set entry.
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
class Score < SafetyKit::Internal::Type::BaseModel
|
|
129
|
+
# @!attribute classifier_id
|
|
130
|
+
# Identifier of the classifier that produced this score.
|
|
131
|
+
#
|
|
132
|
+
# @return [String]
|
|
133
|
+
required :classifier_id, String
|
|
134
|
+
|
|
135
|
+
# @!attribute score
|
|
136
|
+
# Classifier score between 0 and 1. Higher means more likely violating.
|
|
137
|
+
#
|
|
138
|
+
# @return [Float]
|
|
139
|
+
required :score, Float
|
|
140
|
+
|
|
141
|
+
# @!attribute version
|
|
142
|
+
# Version of the classifier that produced this score.
|
|
143
|
+
#
|
|
144
|
+
# @return [String]
|
|
145
|
+
required :version, String
|
|
146
|
+
|
|
147
|
+
# @!method initialize(classifier_id:, score:, version:)
|
|
148
|
+
# Score produced by one classifier for the submitted content.
|
|
149
|
+
#
|
|
150
|
+
# @param classifier_id [String] Identifier of the classifier that produced this score.
|
|
151
|
+
#
|
|
152
|
+
# @param score [Float] Classifier score between 0 and 1. Higher means more likely violating.
|
|
153
|
+
#
|
|
154
|
+
# @param version [String] Version of the classifier that produced this score.
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
end
|
|
@@ -37,7 +37,15 @@ module SafetyKit
|
|
|
37
37
|
# @return [String, nil]
|
|
38
38
|
optional :frame_id, String
|
|
39
39
|
|
|
40
|
-
# @!
|
|
40
|
+
# @!attribute metadata
|
|
41
|
+
# Arbitrary key-value metadata to associate with this frame, at most 8192 bytes
|
|
42
|
+
# when serialized. If a violation is detected on this frame, the metadata is
|
|
43
|
+
# echoed back verbatim in the live_video.violation_detected webhook.
|
|
44
|
+
#
|
|
45
|
+
# @return [Hash{Symbol=>Object, nil}, nil]
|
|
46
|
+
optional :metadata, SafetyKit::Internal::Type::HashOf[SafetyKit::Internal::Type::Unknown, nil?: true]
|
|
47
|
+
|
|
48
|
+
# @!method initialize(namespace:, image_data_uri:, stream_id:, timestamp:, frame_id: nil, metadata: nil, request_options: {})
|
|
41
49
|
# Some parameter documentations has been truncated, see
|
|
42
50
|
# {SafetyKit::Models::StreamAddFrameParams} for more details.
|
|
43
51
|
#
|
|
@@ -51,6 +59,8 @@ module SafetyKit
|
|
|
51
59
|
#
|
|
52
60
|
# @param frame_id [String]
|
|
53
61
|
#
|
|
62
|
+
# @param metadata [Hash{Symbol=>Object, nil}] Arbitrary key-value metadata to associate with this frame, at most 8192 bytes wh
|
|
63
|
+
#
|
|
54
64
|
# @param request_options [SafetyKit::RequestOptions, Hash{Symbol=>Object}]
|
|
55
65
|
end
|
|
56
66
|
end
|
data/lib/safety_kit/models.rb
CHANGED
|
@@ -49,6 +49,8 @@ module SafetyKit
|
|
|
49
49
|
|
|
50
50
|
ClientSessionCreateSessionParams = SafetyKit::Models::ClientSessionCreateSessionParams
|
|
51
51
|
|
|
52
|
+
ContentCreateParams = SafetyKit::Models::ContentCreateParams
|
|
53
|
+
|
|
52
54
|
DataAddParams = SafetyKit::Models::DataAddParams
|
|
53
55
|
|
|
54
56
|
DataCreateUploadURLParams = SafetyKit::Models::DataCreateUploadURLParams
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SafetyKit
|
|
4
|
+
module Resources
|
|
5
|
+
# Classify user-authored text and images synchronously and receive a decision in
|
|
6
|
+
# the response.
|
|
7
|
+
class Content
|
|
8
|
+
# Some parameter documentations has been truncated, see
|
|
9
|
+
# {SafetyKit::Models::ContentCreateParams} for more details.
|
|
10
|
+
#
|
|
11
|
+
# Classify a piece of content synchronously. Send user-authored text, images, or
|
|
12
|
+
# both, and receive a decision (approve, reject, or review) with classifier scores
|
|
13
|
+
# and reference set matches in the response. The full request body must stay under
|
|
14
|
+
# 6MB, which allows roughly 4.4MB of raw image bytes after base64 inflation.
|
|
15
|
+
#
|
|
16
|
+
# @overload create(entity_id:, content_id: nil, images: nil, metadata: nil, text: nil, request_options: {})
|
|
17
|
+
#
|
|
18
|
+
# @param entity_id [String] Your stable identifier for the entity this content belongs to, such as a user, l
|
|
19
|
+
#
|
|
20
|
+
# @param content_id [String] Your identifier for this piece of content — the same content_id you send on /v1/
|
|
21
|
+
#
|
|
22
|
+
# @param images [Array<String>] Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
|
|
23
|
+
#
|
|
24
|
+
# @param metadata [Hash{Symbol=>Object, nil}] Additional product context for this content. At most 8KB when serialized.
|
|
25
|
+
#
|
|
26
|
+
# @param text [String] User-authored text to classify. At most 20000 characters.
|
|
27
|
+
#
|
|
28
|
+
# @param request_options [SafetyKit::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
29
|
+
#
|
|
30
|
+
# @return [SafetyKit::Models::ContentCreateResponse]
|
|
31
|
+
#
|
|
32
|
+
# @see SafetyKit::Models::ContentCreateParams
|
|
33
|
+
def create(params)
|
|
34
|
+
parsed, options = SafetyKit::ContentCreateParams.dump_request(params)
|
|
35
|
+
@client.request(
|
|
36
|
+
method: :post,
|
|
37
|
+
path: "v1/content",
|
|
38
|
+
body: parsed,
|
|
39
|
+
model: SafetyKit::Models::ContentCreateResponse,
|
|
40
|
+
options: options
|
|
41
|
+
)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# @api private
|
|
45
|
+
#
|
|
46
|
+
# @param client [SafetyKit::Client]
|
|
47
|
+
def initialize(client:)
|
|
48
|
+
@client = client
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -43,7 +43,7 @@ module SafetyKit
|
|
|
43
43
|
# ignored by downstream processing. This method returns immediately after the
|
|
44
44
|
# frame has been accepted for processing.
|
|
45
45
|
#
|
|
46
|
-
# @overload add_frame(namespace, image_data_uri:, stream_id:, timestamp:, frame_id: nil, request_options: {})
|
|
46
|
+
# @overload add_frame(namespace, image_data_uri:, stream_id:, timestamp:, frame_id: nil, metadata: nil, request_options: {})
|
|
47
47
|
#
|
|
48
48
|
# @param namespace [String] The namespace to ingest stream data into
|
|
49
49
|
#
|
|
@@ -55,6 +55,8 @@ module SafetyKit
|
|
|
55
55
|
#
|
|
56
56
|
# @param frame_id [String]
|
|
57
57
|
#
|
|
58
|
+
# @param metadata [Hash{Symbol=>Object, nil}] Arbitrary key-value metadata to associate with this frame, at most 8192 bytes wh
|
|
59
|
+
#
|
|
58
60
|
# @param request_options [SafetyKit::RequestOptions, Hash{Symbol=>Object}, nil]
|
|
59
61
|
#
|
|
60
62
|
# @return [SafetyKit::Models::StreamAddFrameResponse]
|
data/lib/safety_kit/version.rb
CHANGED
data/lib/safety_kit.rb
CHANGED
|
@@ -62,6 +62,8 @@ require_relative "safety_kit/models/beta/event_create_params"
|
|
|
62
62
|
require_relative "safety_kit/models/beta/event_create_response"
|
|
63
63
|
require_relative "safety_kit/models/client_session_create_session_params"
|
|
64
64
|
require_relative "safety_kit/models/client_session_create_session_response"
|
|
65
|
+
require_relative "safety_kit/models/content_create_params"
|
|
66
|
+
require_relative "safety_kit/models/content_create_response"
|
|
65
67
|
require_relative "safety_kit/models/data_add_params"
|
|
66
68
|
require_relative "safety_kit/models/data_add_response"
|
|
67
69
|
require_relative "safety_kit/models/data_create_upload_url_params"
|
|
@@ -88,6 +90,7 @@ require_relative "safety_kit/resources/async"
|
|
|
88
90
|
require_relative "safety_kit/resources/beta"
|
|
89
91
|
require_relative "safety_kit/resources/beta/events"
|
|
90
92
|
require_relative "safety_kit/resources/client_sessions"
|
|
93
|
+
require_relative "safety_kit/resources/content"
|
|
91
94
|
require_relative "safety_kit/resources/data"
|
|
92
95
|
require_relative "safety_kit/resources/deletion_requests"
|
|
93
96
|
require_relative "safety_kit/resources/streams"
|
data/rbi/safety_kit/client.rbi
CHANGED
|
@@ -37,6 +37,11 @@ module SafetyKit
|
|
|
37
37
|
sig { returns(SafetyKit::Resources::Async) }
|
|
38
38
|
attr_reader :async
|
|
39
39
|
|
|
40
|
+
# Classify user-authored text and images synchronously and receive a decision in
|
|
41
|
+
# the response.
|
|
42
|
+
sig { returns(SafetyKit::Resources::Content) }
|
|
43
|
+
attr_reader :content
|
|
44
|
+
|
|
40
45
|
# Submit end-user deletion requests. Accepted requests are processed
|
|
41
46
|
# asynchronously.
|
|
42
47
|
sig { returns(SafetyKit::Resources::DeletionRequests) }
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module SafetyKit
|
|
4
|
+
module Models
|
|
5
|
+
class ContentCreateParams < SafetyKit::Internal::Type::BaseModel
|
|
6
|
+
extend SafetyKit::Internal::Type::RequestParameters::Converter
|
|
7
|
+
include SafetyKit::Internal::Type::RequestParameters
|
|
8
|
+
|
|
9
|
+
OrHash =
|
|
10
|
+
T.type_alias do
|
|
11
|
+
T.any(SafetyKit::ContentCreateParams, SafetyKit::Internal::AnyHash)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Your stable identifier for the entity this content belongs to, such as a user,
|
|
15
|
+
# listing, or message thread.
|
|
16
|
+
sig { returns(String) }
|
|
17
|
+
attr_accessor :entity_id
|
|
18
|
+
|
|
19
|
+
# Your identifier for this piece of content — the same content_id you send on
|
|
20
|
+
# /v1/events. When provided, the event this call records deduplicates against the
|
|
21
|
+
# same upload posted through the events API, so sending both never double-counts
|
|
22
|
+
# the content.
|
|
23
|
+
sig { returns(T.nilable(String)) }
|
|
24
|
+
attr_reader :content_id
|
|
25
|
+
|
|
26
|
+
sig { params(content_id: String).void }
|
|
27
|
+
attr_writer :content_id
|
|
28
|
+
|
|
29
|
+
# Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
|
|
30
|
+
# most 4 images. The full request body must stay under 6MB, which allows roughly
|
|
31
|
+
# 4.4MB of raw image bytes after base64 inflation.
|
|
32
|
+
sig { returns(T.nilable(T::Array[String])) }
|
|
33
|
+
attr_reader :images
|
|
34
|
+
|
|
35
|
+
sig { params(images: T::Array[String]).void }
|
|
36
|
+
attr_writer :images
|
|
37
|
+
|
|
38
|
+
# Additional product context for this content. At most 8KB when serialized.
|
|
39
|
+
sig { returns(T.nilable(T::Hash[Symbol, T.nilable(T.anything)])) }
|
|
40
|
+
attr_reader :metadata
|
|
41
|
+
|
|
42
|
+
sig { params(metadata: T::Hash[Symbol, T.nilable(T.anything)]).void }
|
|
43
|
+
attr_writer :metadata
|
|
44
|
+
|
|
45
|
+
# User-authored text to classify. At most 20000 characters.
|
|
46
|
+
sig { returns(T.nilable(String)) }
|
|
47
|
+
attr_reader :text
|
|
48
|
+
|
|
49
|
+
sig { params(text: String).void }
|
|
50
|
+
attr_writer :text
|
|
51
|
+
|
|
52
|
+
sig do
|
|
53
|
+
params(
|
|
54
|
+
entity_id: String,
|
|
55
|
+
content_id: String,
|
|
56
|
+
images: T::Array[String],
|
|
57
|
+
metadata: T::Hash[Symbol, T.nilable(T.anything)],
|
|
58
|
+
text: String,
|
|
59
|
+
request_options: SafetyKit::RequestOptions::OrHash
|
|
60
|
+
).returns(T.attached_class)
|
|
61
|
+
end
|
|
62
|
+
def self.new(
|
|
63
|
+
# Your stable identifier for the entity this content belongs to, such as a user,
|
|
64
|
+
# listing, or message thread.
|
|
65
|
+
entity_id:,
|
|
66
|
+
# Your identifier for this piece of content — the same content_id you send on
|
|
67
|
+
# /v1/events. When provided, the event this call records deduplicates against the
|
|
68
|
+
# same upload posted through the events API, so sending both never double-counts
|
|
69
|
+
# the content.
|
|
70
|
+
content_id: nil,
|
|
71
|
+
# Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
|
|
72
|
+
# most 4 images. The full request body must stay under 6MB, which allows roughly
|
|
73
|
+
# 4.4MB of raw image bytes after base64 inflation.
|
|
74
|
+
images: nil,
|
|
75
|
+
# Additional product context for this content. At most 8KB when serialized.
|
|
76
|
+
metadata: nil,
|
|
77
|
+
# User-authored text to classify. At most 20000 characters.
|
|
78
|
+
text: nil,
|
|
79
|
+
request_options: {}
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
sig do
|
|
84
|
+
override.returns(
|
|
85
|
+
{
|
|
86
|
+
entity_id: String,
|
|
87
|
+
content_id: String,
|
|
88
|
+
images: T::Array[String],
|
|
89
|
+
metadata: T::Hash[Symbol, T.nilable(T.anything)],
|
|
90
|
+
text: String,
|
|
91
|
+
request_options: SafetyKit::RequestOptions
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
end
|
|
95
|
+
def to_hash
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module SafetyKit
|
|
4
|
+
module Models
|
|
5
|
+
class ContentCreateResponse < SafetyKit::Internal::Type::BaseModel
|
|
6
|
+
OrHash =
|
|
7
|
+
T.type_alias do
|
|
8
|
+
T.any(
|
|
9
|
+
SafetyKit::Models::ContentCreateResponse,
|
|
10
|
+
SafetyKit::Internal::AnyHash
|
|
11
|
+
)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# SafetyKit identifier for the classified content.
|
|
15
|
+
sig { returns(String) }
|
|
16
|
+
attr_accessor :content_id
|
|
17
|
+
|
|
18
|
+
# SafetyKit's decision for the submitted content: approve (no violation found),
|
|
19
|
+
# reject (violating), or review (needs human review).
|
|
20
|
+
sig do
|
|
21
|
+
returns(
|
|
22
|
+
SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
attr_accessor :decision
|
|
26
|
+
|
|
27
|
+
# The entity_id from the request.
|
|
28
|
+
sig { returns(String) }
|
|
29
|
+
attr_accessor :entity_id
|
|
30
|
+
|
|
31
|
+
# Escalation outcome for this request: none (the request never entered the
|
|
32
|
+
# escalation band), completed (the escalated verdict is reflected in decision), or
|
|
33
|
+
# timed_out (escalation did not finish in budget, so decision is a provisional
|
|
34
|
+
# review).
|
|
35
|
+
sig do
|
|
36
|
+
returns(
|
|
37
|
+
SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
|
|
38
|
+
)
|
|
39
|
+
end
|
|
40
|
+
attr_accessor :escalation
|
|
41
|
+
|
|
42
|
+
# Whether SafetyKit mirrored the submitted content for later review.
|
|
43
|
+
sig { returns(T::Boolean) }
|
|
44
|
+
attr_accessor :mirrored
|
|
45
|
+
|
|
46
|
+
# Reference set matches found for the submitted content.
|
|
47
|
+
sig do
|
|
48
|
+
returns(
|
|
49
|
+
T::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch]
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
attr_accessor :reference_set_matches
|
|
53
|
+
|
|
54
|
+
# Classifier scores produced for the submitted content.
|
|
55
|
+
sig { returns(T::Array[SafetyKit::Models::ContentCreateResponse::Score]) }
|
|
56
|
+
attr_accessor :scores
|
|
57
|
+
|
|
58
|
+
# Synchronous classification result for the submitted content.
|
|
59
|
+
sig do
|
|
60
|
+
params(
|
|
61
|
+
content_id: String,
|
|
62
|
+
decision:
|
|
63
|
+
SafetyKit::Models::ContentCreateResponse::Decision::OrSymbol,
|
|
64
|
+
entity_id: String,
|
|
65
|
+
escalation:
|
|
66
|
+
SafetyKit::Models::ContentCreateResponse::Escalation::OrSymbol,
|
|
67
|
+
mirrored: T::Boolean,
|
|
68
|
+
reference_set_matches:
|
|
69
|
+
T::Array[
|
|
70
|
+
SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch::OrHash
|
|
71
|
+
],
|
|
72
|
+
scores:
|
|
73
|
+
T::Array[SafetyKit::Models::ContentCreateResponse::Score::OrHash]
|
|
74
|
+
).returns(T.attached_class)
|
|
75
|
+
end
|
|
76
|
+
def self.new(
|
|
77
|
+
# SafetyKit identifier for the classified content.
|
|
78
|
+
content_id:,
|
|
79
|
+
# SafetyKit's decision for the submitted content: approve (no violation found),
|
|
80
|
+
# reject (violating), or review (needs human review).
|
|
81
|
+
decision:,
|
|
82
|
+
# The entity_id from the request.
|
|
83
|
+
entity_id:,
|
|
84
|
+
# Escalation outcome for this request: none (the request never entered the
|
|
85
|
+
# escalation band), completed (the escalated verdict is reflected in decision), or
|
|
86
|
+
# timed_out (escalation did not finish in budget, so decision is a provisional
|
|
87
|
+
# review).
|
|
88
|
+
escalation:,
|
|
89
|
+
# Whether SafetyKit mirrored the submitted content for later review.
|
|
90
|
+
mirrored:,
|
|
91
|
+
# Reference set matches found for the submitted content.
|
|
92
|
+
reference_set_matches:,
|
|
93
|
+
# Classifier scores produced for the submitted content.
|
|
94
|
+
scores:
|
|
95
|
+
)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
sig do
|
|
99
|
+
override.returns(
|
|
100
|
+
{
|
|
101
|
+
content_id: String,
|
|
102
|
+
decision:
|
|
103
|
+
SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol,
|
|
104
|
+
entity_id: String,
|
|
105
|
+
escalation:
|
|
106
|
+
SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol,
|
|
107
|
+
mirrored: T::Boolean,
|
|
108
|
+
reference_set_matches:
|
|
109
|
+
T::Array[
|
|
110
|
+
SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch
|
|
111
|
+
],
|
|
112
|
+
scores: T::Array[SafetyKit::Models::ContentCreateResponse::Score]
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
end
|
|
116
|
+
def to_hash
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# SafetyKit's decision for the submitted content: approve (no violation found),
|
|
120
|
+
# reject (violating), or review (needs human review).
|
|
121
|
+
module Decision
|
|
122
|
+
extend SafetyKit::Internal::Type::Enum
|
|
123
|
+
|
|
124
|
+
TaggedSymbol =
|
|
125
|
+
T.type_alias do
|
|
126
|
+
T.all(Symbol, SafetyKit::Models::ContentCreateResponse::Decision)
|
|
127
|
+
end
|
|
128
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
129
|
+
|
|
130
|
+
APPROVE =
|
|
131
|
+
T.let(
|
|
132
|
+
:approve,
|
|
133
|
+
SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
|
|
134
|
+
)
|
|
135
|
+
REJECT =
|
|
136
|
+
T.let(
|
|
137
|
+
:reject,
|
|
138
|
+
SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
|
|
139
|
+
)
|
|
140
|
+
REVIEW =
|
|
141
|
+
T.let(
|
|
142
|
+
:review,
|
|
143
|
+
SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
sig do
|
|
147
|
+
override.returns(
|
|
148
|
+
T::Array[
|
|
149
|
+
SafetyKit::Models::ContentCreateResponse::Decision::TaggedSymbol
|
|
150
|
+
]
|
|
151
|
+
)
|
|
152
|
+
end
|
|
153
|
+
def self.values
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Escalation outcome for this request: none (the request never entered the
|
|
158
|
+
# escalation band), completed (the escalated verdict is reflected in decision), or
|
|
159
|
+
# timed_out (escalation did not finish in budget, so decision is a provisional
|
|
160
|
+
# review).
|
|
161
|
+
module Escalation
|
|
162
|
+
extend SafetyKit::Internal::Type::Enum
|
|
163
|
+
|
|
164
|
+
TaggedSymbol =
|
|
165
|
+
T.type_alias do
|
|
166
|
+
T.all(Symbol, SafetyKit::Models::ContentCreateResponse::Escalation)
|
|
167
|
+
end
|
|
168
|
+
OrSymbol = T.type_alias { T.any(Symbol, String) }
|
|
169
|
+
|
|
170
|
+
NONE =
|
|
171
|
+
T.let(
|
|
172
|
+
:none,
|
|
173
|
+
SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
|
|
174
|
+
)
|
|
175
|
+
COMPLETED =
|
|
176
|
+
T.let(
|
|
177
|
+
:completed,
|
|
178
|
+
SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
|
|
179
|
+
)
|
|
180
|
+
TIMED_OUT =
|
|
181
|
+
T.let(
|
|
182
|
+
:timed_out,
|
|
183
|
+
SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
sig do
|
|
187
|
+
override.returns(
|
|
188
|
+
T::Array[
|
|
189
|
+
SafetyKit::Models::ContentCreateResponse::Escalation::TaggedSymbol
|
|
190
|
+
]
|
|
191
|
+
)
|
|
192
|
+
end
|
|
193
|
+
def self.values
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
class ReferenceSetMatch < SafetyKit::Internal::Type::BaseModel
|
|
198
|
+
OrHash =
|
|
199
|
+
T.type_alias do
|
|
200
|
+
T.any(
|
|
201
|
+
SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch,
|
|
202
|
+
SafetyKit::Internal::AnyHash
|
|
203
|
+
)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Identifier of the matched reference set.
|
|
207
|
+
sig { returns(String) }
|
|
208
|
+
attr_accessor :set_id
|
|
209
|
+
|
|
210
|
+
# Similarity between the submitted content and the matched reference set entry.
|
|
211
|
+
sig { returns(Float) }
|
|
212
|
+
attr_accessor :similarity
|
|
213
|
+
|
|
214
|
+
# Reference set match found for the submitted content.
|
|
215
|
+
sig do
|
|
216
|
+
params(set_id: String, similarity: Float).returns(T.attached_class)
|
|
217
|
+
end
|
|
218
|
+
def self.new(
|
|
219
|
+
# Identifier of the matched reference set.
|
|
220
|
+
set_id:,
|
|
221
|
+
# Similarity between the submitted content and the matched reference set entry.
|
|
222
|
+
similarity:
|
|
223
|
+
)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
sig { override.returns({ set_id: String, similarity: Float }) }
|
|
227
|
+
def to_hash
|
|
228
|
+
end
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
class Score < SafetyKit::Internal::Type::BaseModel
|
|
232
|
+
OrHash =
|
|
233
|
+
T.type_alias do
|
|
234
|
+
T.any(
|
|
235
|
+
SafetyKit::Models::ContentCreateResponse::Score,
|
|
236
|
+
SafetyKit::Internal::AnyHash
|
|
237
|
+
)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# Identifier of the classifier that produced this score.
|
|
241
|
+
sig { returns(String) }
|
|
242
|
+
attr_accessor :classifier_id
|
|
243
|
+
|
|
244
|
+
# Classifier score between 0 and 1. Higher means more likely violating.
|
|
245
|
+
sig { returns(Float) }
|
|
246
|
+
attr_accessor :score
|
|
247
|
+
|
|
248
|
+
# Version of the classifier that produced this score.
|
|
249
|
+
sig { returns(String) }
|
|
250
|
+
attr_accessor :version
|
|
251
|
+
|
|
252
|
+
# Score produced by one classifier for the submitted content.
|
|
253
|
+
sig do
|
|
254
|
+
params(classifier_id: String, score: Float, version: String).returns(
|
|
255
|
+
T.attached_class
|
|
256
|
+
)
|
|
257
|
+
end
|
|
258
|
+
def self.new(
|
|
259
|
+
# Identifier of the classifier that produced this score.
|
|
260
|
+
classifier_id:,
|
|
261
|
+
# Classifier score between 0 and 1. Higher means more likely violating.
|
|
262
|
+
score:,
|
|
263
|
+
# Version of the classifier that produced this score.
|
|
264
|
+
version:
|
|
265
|
+
)
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
sig do
|
|
269
|
+
override.returns(
|
|
270
|
+
{ classifier_id: String, score: Float, version: String }
|
|
271
|
+
)
|
|
272
|
+
end
|
|
273
|
+
def to_hash
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
end
|
|
@@ -34,6 +34,15 @@ module SafetyKit
|
|
|
34
34
|
sig { params(frame_id: String).void }
|
|
35
35
|
attr_writer :frame_id
|
|
36
36
|
|
|
37
|
+
# Arbitrary key-value metadata to associate with this frame, at most 8192 bytes
|
|
38
|
+
# when serialized. If a violation is detected on this frame, the metadata is
|
|
39
|
+
# echoed back verbatim in the live_video.violation_detected webhook.
|
|
40
|
+
sig { returns(T.nilable(T::Hash[Symbol, T.nilable(T.anything)])) }
|
|
41
|
+
attr_reader :metadata
|
|
42
|
+
|
|
43
|
+
sig { params(metadata: T::Hash[Symbol, T.nilable(T.anything)]).void }
|
|
44
|
+
attr_writer :metadata
|
|
45
|
+
|
|
37
46
|
sig do
|
|
38
47
|
params(
|
|
39
48
|
namespace: String,
|
|
@@ -41,6 +50,7 @@ module SafetyKit
|
|
|
41
50
|
stream_id: String,
|
|
42
51
|
timestamp: Integer,
|
|
43
52
|
frame_id: String,
|
|
53
|
+
metadata: T::Hash[Symbol, T.nilable(T.anything)],
|
|
44
54
|
request_options: SafetyKit::RequestOptions::OrHash
|
|
45
55
|
).returns(T.attached_class)
|
|
46
56
|
end
|
|
@@ -55,6 +65,10 @@ module SafetyKit
|
|
|
55
65
|
stream_id:,
|
|
56
66
|
timestamp:,
|
|
57
67
|
frame_id: nil,
|
|
68
|
+
# Arbitrary key-value metadata to associate with this frame, at most 8192 bytes
|
|
69
|
+
# when serialized. If a violation is detected on this frame, the metadata is
|
|
70
|
+
# echoed back verbatim in the live_video.violation_detected webhook.
|
|
71
|
+
metadata: nil,
|
|
58
72
|
request_options: {}
|
|
59
73
|
)
|
|
60
74
|
end
|
|
@@ -67,6 +81,7 @@ module SafetyKit
|
|
|
67
81
|
stream_id: String,
|
|
68
82
|
timestamp: Integer,
|
|
69
83
|
frame_id: String,
|
|
84
|
+
metadata: T::Hash[Symbol, T.nilable(T.anything)],
|
|
70
85
|
request_options: SafetyKit::RequestOptions
|
|
71
86
|
}
|
|
72
87
|
)
|
data/rbi/safety_kit/models.rbi
CHANGED
|
@@ -14,6 +14,8 @@ module SafetyKit
|
|
|
14
14
|
ClientSessionCreateSessionParams =
|
|
15
15
|
SafetyKit::Models::ClientSessionCreateSessionParams
|
|
16
16
|
|
|
17
|
+
ContentCreateParams = SafetyKit::Models::ContentCreateParams
|
|
18
|
+
|
|
17
19
|
DataAddParams = SafetyKit::Models::DataAddParams
|
|
18
20
|
|
|
19
21
|
DataCreateUploadURLParams = SafetyKit::Models::DataCreateUploadURLParams
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module SafetyKit
|
|
4
|
+
module Resources
|
|
5
|
+
# Classify user-authored text and images synchronously and receive a decision in
|
|
6
|
+
# the response.
|
|
7
|
+
class Content
|
|
8
|
+
# Classify a piece of content synchronously. Send user-authored text, images, or
|
|
9
|
+
# both, and receive a decision (approve, reject, or review) with classifier scores
|
|
10
|
+
# and reference set matches in the response. The full request body must stay under
|
|
11
|
+
# 6MB, which allows roughly 4.4MB of raw image bytes after base64 inflation.
|
|
12
|
+
sig do
|
|
13
|
+
params(
|
|
14
|
+
entity_id: String,
|
|
15
|
+
content_id: String,
|
|
16
|
+
images: T::Array[String],
|
|
17
|
+
metadata: T::Hash[Symbol, T.nilable(T.anything)],
|
|
18
|
+
text: String,
|
|
19
|
+
request_options: SafetyKit::RequestOptions::OrHash
|
|
20
|
+
).returns(SafetyKit::Models::ContentCreateResponse)
|
|
21
|
+
end
|
|
22
|
+
def create(
|
|
23
|
+
# Your stable identifier for the entity this content belongs to, such as a user,
|
|
24
|
+
# listing, or message thread.
|
|
25
|
+
entity_id:,
|
|
26
|
+
# Your identifier for this piece of content — the same content_id you send on
|
|
27
|
+
# /v1/events. When provided, the event this call records deduplicates against the
|
|
28
|
+
# same upload posted through the events API, so sending both never double-counts
|
|
29
|
+
# the content.
|
|
30
|
+
content_id: nil,
|
|
31
|
+
# Images to classify, each as base64-encoded image bytes, raw or as a data URI. At
|
|
32
|
+
# most 4 images. The full request body must stay under 6MB, which allows roughly
|
|
33
|
+
# 4.4MB of raw image bytes after base64 inflation.
|
|
34
|
+
images: nil,
|
|
35
|
+
# Additional product context for this content. At most 8KB when serialized.
|
|
36
|
+
metadata: nil,
|
|
37
|
+
# User-authored text to classify. At most 20000 characters.
|
|
38
|
+
text: nil,
|
|
39
|
+
request_options: {}
|
|
40
|
+
)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# @api private
|
|
44
|
+
sig { params(client: SafetyKit::Client).returns(T.attached_class) }
|
|
45
|
+
def self.new(client:)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -38,6 +38,7 @@ module SafetyKit
|
|
|
38
38
|
stream_id: String,
|
|
39
39
|
timestamp: Integer,
|
|
40
40
|
frame_id: String,
|
|
41
|
+
metadata: T::Hash[Symbol, T.nilable(T.anything)],
|
|
41
42
|
request_options: SafetyKit::RequestOptions::OrHash
|
|
42
43
|
).returns(SafetyKit::Models::StreamAddFrameResponse)
|
|
43
44
|
end
|
|
@@ -52,6 +53,10 @@ module SafetyKit
|
|
|
52
53
|
stream_id:,
|
|
53
54
|
timestamp:,
|
|
54
55
|
frame_id: nil,
|
|
56
|
+
# Arbitrary key-value metadata to associate with this frame, at most 8192 bytes
|
|
57
|
+
# when serialized. If a violation is detected on this frame, the metadata is
|
|
58
|
+
# echoed back verbatim in the live_video.violation_detected webhook.
|
|
59
|
+
metadata: nil,
|
|
55
60
|
request_options: {}
|
|
56
61
|
)
|
|
57
62
|
end
|
data/sig/safety_kit/client.rbs
CHANGED
|
@@ -20,6 +20,8 @@ module SafetyKit
|
|
|
20
20
|
|
|
21
21
|
attr_reader async: SafetyKit::Resources::Async
|
|
22
22
|
|
|
23
|
+
attr_reader content: SafetyKit::Resources::Content
|
|
24
|
+
|
|
23
25
|
attr_reader deletion_requests: SafetyKit::Resources::DeletionRequests
|
|
24
26
|
|
|
25
27
|
attr_reader client_sessions: SafetyKit::Resources::ClientSessions
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module SafetyKit
|
|
2
|
+
module Models
|
|
3
|
+
type content_create_params =
|
|
4
|
+
{
|
|
5
|
+
entity_id: String,
|
|
6
|
+
content_id: String,
|
|
7
|
+
images: ::Array[String],
|
|
8
|
+
metadata: ::Hash[Symbol, top?],
|
|
9
|
+
text: String
|
|
10
|
+
}
|
|
11
|
+
& SafetyKit::Internal::Type::request_parameters
|
|
12
|
+
|
|
13
|
+
class ContentCreateParams < SafetyKit::Internal::Type::BaseModel
|
|
14
|
+
extend SafetyKit::Internal::Type::RequestParameters::Converter
|
|
15
|
+
include SafetyKit::Internal::Type::RequestParameters
|
|
16
|
+
|
|
17
|
+
attr_accessor entity_id: String
|
|
18
|
+
|
|
19
|
+
attr_reader content_id: String?
|
|
20
|
+
|
|
21
|
+
def content_id=: (String) -> String
|
|
22
|
+
|
|
23
|
+
attr_reader images: ::Array[String]?
|
|
24
|
+
|
|
25
|
+
def images=: (::Array[String]) -> ::Array[String]
|
|
26
|
+
|
|
27
|
+
attr_reader metadata: ::Hash[Symbol, top?]?
|
|
28
|
+
|
|
29
|
+
def metadata=: (::Hash[Symbol, top?]) -> ::Hash[Symbol, top?]
|
|
30
|
+
|
|
31
|
+
attr_reader text: String?
|
|
32
|
+
|
|
33
|
+
def text=: (String) -> String
|
|
34
|
+
|
|
35
|
+
def initialize: (
|
|
36
|
+
entity_id: String,
|
|
37
|
+
?content_id: String,
|
|
38
|
+
?images: ::Array[String],
|
|
39
|
+
?metadata: ::Hash[Symbol, top?],
|
|
40
|
+
?text: String,
|
|
41
|
+
?request_options: SafetyKit::request_opts
|
|
42
|
+
) -> void
|
|
43
|
+
|
|
44
|
+
def to_hash: -> {
|
|
45
|
+
entity_id: String,
|
|
46
|
+
content_id: String,
|
|
47
|
+
images: ::Array[String],
|
|
48
|
+
metadata: ::Hash[Symbol, top?],
|
|
49
|
+
text: String,
|
|
50
|
+
request_options: SafetyKit::RequestOptions
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module SafetyKit
|
|
2
|
+
module Models
|
|
3
|
+
type content_create_response =
|
|
4
|
+
{
|
|
5
|
+
content_id: String,
|
|
6
|
+
decision: SafetyKit::Models::ContentCreateResponse::decision,
|
|
7
|
+
entity_id: String,
|
|
8
|
+
escalation: SafetyKit::Models::ContentCreateResponse::escalation,
|
|
9
|
+
mirrored: bool,
|
|
10
|
+
reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
|
|
11
|
+
scores: ::Array[SafetyKit::Models::ContentCreateResponse::Score]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class ContentCreateResponse < SafetyKit::Internal::Type::BaseModel
|
|
15
|
+
attr_accessor content_id: String
|
|
16
|
+
|
|
17
|
+
attr_accessor decision: SafetyKit::Models::ContentCreateResponse::decision
|
|
18
|
+
|
|
19
|
+
attr_accessor entity_id: String
|
|
20
|
+
|
|
21
|
+
attr_accessor escalation: SafetyKit::Models::ContentCreateResponse::escalation
|
|
22
|
+
|
|
23
|
+
attr_accessor mirrored: bool
|
|
24
|
+
|
|
25
|
+
attr_accessor reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch]
|
|
26
|
+
|
|
27
|
+
attr_accessor scores: ::Array[SafetyKit::Models::ContentCreateResponse::Score]
|
|
28
|
+
|
|
29
|
+
def initialize: (
|
|
30
|
+
content_id: String,
|
|
31
|
+
decision: SafetyKit::Models::ContentCreateResponse::decision,
|
|
32
|
+
entity_id: String,
|
|
33
|
+
escalation: SafetyKit::Models::ContentCreateResponse::escalation,
|
|
34
|
+
mirrored: bool,
|
|
35
|
+
reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
|
|
36
|
+
scores: ::Array[SafetyKit::Models::ContentCreateResponse::Score]
|
|
37
|
+
) -> void
|
|
38
|
+
|
|
39
|
+
def to_hash: -> {
|
|
40
|
+
content_id: String,
|
|
41
|
+
decision: SafetyKit::Models::ContentCreateResponse::decision,
|
|
42
|
+
entity_id: String,
|
|
43
|
+
escalation: SafetyKit::Models::ContentCreateResponse::escalation,
|
|
44
|
+
mirrored: bool,
|
|
45
|
+
reference_set_matches: ::Array[SafetyKit::Models::ContentCreateResponse::ReferenceSetMatch],
|
|
46
|
+
scores: ::Array[SafetyKit::Models::ContentCreateResponse::Score]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type decision = :approve | :reject | :review
|
|
50
|
+
|
|
51
|
+
module Decision
|
|
52
|
+
extend SafetyKit::Internal::Type::Enum
|
|
53
|
+
|
|
54
|
+
APPROVE: :approve
|
|
55
|
+
REJECT: :reject
|
|
56
|
+
REVIEW: :review
|
|
57
|
+
|
|
58
|
+
def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::decision]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
type escalation = :none | :completed | :timed_out
|
|
62
|
+
|
|
63
|
+
module Escalation
|
|
64
|
+
extend SafetyKit::Internal::Type::Enum
|
|
65
|
+
|
|
66
|
+
NONE: :none
|
|
67
|
+
COMPLETED: :completed
|
|
68
|
+
TIMED_OUT: :timed_out
|
|
69
|
+
|
|
70
|
+
def self?.values: -> ::Array[SafetyKit::Models::ContentCreateResponse::escalation]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
type reference_set_match = { set_id: String, similarity: Float }
|
|
74
|
+
|
|
75
|
+
class ReferenceSetMatch < SafetyKit::Internal::Type::BaseModel
|
|
76
|
+
attr_accessor set_id: String
|
|
77
|
+
|
|
78
|
+
attr_accessor similarity: Float
|
|
79
|
+
|
|
80
|
+
def initialize: (set_id: String, similarity: Float) -> void
|
|
81
|
+
|
|
82
|
+
def to_hash: -> { set_id: String, similarity: Float }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
type score = { classifier_id: String, score: Float, version: String }
|
|
86
|
+
|
|
87
|
+
class Score < SafetyKit::Internal::Type::BaseModel
|
|
88
|
+
attr_accessor classifier_id: String
|
|
89
|
+
|
|
90
|
+
attr_accessor score: Float
|
|
91
|
+
|
|
92
|
+
attr_accessor version: String
|
|
93
|
+
|
|
94
|
+
def initialize: (
|
|
95
|
+
classifier_id: String,
|
|
96
|
+
score: Float,
|
|
97
|
+
version: String
|
|
98
|
+
) -> void
|
|
99
|
+
|
|
100
|
+
def to_hash: -> { classifier_id: String, score: Float, version: String }
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -6,7 +6,8 @@ module SafetyKit
|
|
|
6
6
|
image_data_uri: String,
|
|
7
7
|
stream_id: String,
|
|
8
8
|
timestamp: Integer,
|
|
9
|
-
frame_id: String
|
|
9
|
+
frame_id: String,
|
|
10
|
+
metadata: ::Hash[Symbol, top?]
|
|
10
11
|
}
|
|
11
12
|
& SafetyKit::Internal::Type::request_parameters
|
|
12
13
|
|
|
@@ -26,12 +27,17 @@ module SafetyKit
|
|
|
26
27
|
|
|
27
28
|
def frame_id=: (String) -> String
|
|
28
29
|
|
|
30
|
+
attr_reader metadata: ::Hash[Symbol, top?]?
|
|
31
|
+
|
|
32
|
+
def metadata=: (::Hash[Symbol, top?]) -> ::Hash[Symbol, top?]
|
|
33
|
+
|
|
29
34
|
def initialize: (
|
|
30
35
|
namespace: String,
|
|
31
36
|
image_data_uri: String,
|
|
32
37
|
stream_id: String,
|
|
33
38
|
timestamp: Integer,
|
|
34
39
|
?frame_id: String,
|
|
40
|
+
?metadata: ::Hash[Symbol, top?],
|
|
35
41
|
?request_options: SafetyKit::request_opts
|
|
36
42
|
) -> void
|
|
37
43
|
|
|
@@ -41,6 +47,7 @@ module SafetyKit
|
|
|
41
47
|
stream_id: String,
|
|
42
48
|
timestamp: Integer,
|
|
43
49
|
frame_id: String,
|
|
50
|
+
metadata: ::Hash[Symbol, top?],
|
|
44
51
|
request_options: SafetyKit::RequestOptions
|
|
45
52
|
}
|
|
46
53
|
end
|
data/sig/safety_kit/models.rbs
CHANGED
|
@@ -9,6 +9,8 @@ module SafetyKit
|
|
|
9
9
|
|
|
10
10
|
class ClientSessionCreateSessionParams = SafetyKit::Models::ClientSessionCreateSessionParams
|
|
11
11
|
|
|
12
|
+
class ContentCreateParams = SafetyKit::Models::ContentCreateParams
|
|
13
|
+
|
|
12
14
|
class DataAddParams = SafetyKit::Models::DataAddParams
|
|
13
15
|
|
|
14
16
|
class DataCreateUploadURLParams = SafetyKit::Models::DataCreateUploadURLParams
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module SafetyKit
|
|
2
|
+
module Resources
|
|
3
|
+
class Content
|
|
4
|
+
def create: (
|
|
5
|
+
entity_id: String,
|
|
6
|
+
?content_id: String,
|
|
7
|
+
?images: ::Array[String],
|
|
8
|
+
?metadata: ::Hash[Symbol, top?],
|
|
9
|
+
?text: String,
|
|
10
|
+
?request_options: SafetyKit::request_opts
|
|
11
|
+
) -> SafetyKit::Models::ContentCreateResponse
|
|
12
|
+
|
|
13
|
+
def initialize: (client: SafetyKit::Client) -> void
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: safetykit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.51.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Safetykit
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-08-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cgi
|
|
@@ -79,6 +79,8 @@ files:
|
|
|
79
79
|
- lib/safety_kit/models/beta/event_create_response.rb
|
|
80
80
|
- lib/safety_kit/models/client_session_create_session_params.rb
|
|
81
81
|
- lib/safety_kit/models/client_session_create_session_response.rb
|
|
82
|
+
- lib/safety_kit/models/content_create_params.rb
|
|
83
|
+
- lib/safety_kit/models/content_create_response.rb
|
|
82
84
|
- lib/safety_kit/models/data_add_params.rb
|
|
83
85
|
- lib/safety_kit/models/data_add_response.rb
|
|
84
86
|
- lib/safety_kit/models/data_create_upload_url_params.rb
|
|
@@ -105,6 +107,7 @@ files:
|
|
|
105
107
|
- lib/safety_kit/resources/beta.rb
|
|
106
108
|
- lib/safety_kit/resources/beta/events.rb
|
|
107
109
|
- lib/safety_kit/resources/client_sessions.rb
|
|
110
|
+
- lib/safety_kit/resources/content.rb
|
|
108
111
|
- lib/safety_kit/resources/data.rb
|
|
109
112
|
- lib/safety_kit/resources/deletion_requests.rb
|
|
110
113
|
- lib/safety_kit/resources/streams.rb
|
|
@@ -139,6 +142,8 @@ files:
|
|
|
139
142
|
- rbi/safety_kit/models/beta/event_create_response.rbi
|
|
140
143
|
- rbi/safety_kit/models/client_session_create_session_params.rbi
|
|
141
144
|
- rbi/safety_kit/models/client_session_create_session_response.rbi
|
|
145
|
+
- rbi/safety_kit/models/content_create_params.rbi
|
|
146
|
+
- rbi/safety_kit/models/content_create_response.rbi
|
|
142
147
|
- rbi/safety_kit/models/data_add_params.rbi
|
|
143
148
|
- rbi/safety_kit/models/data_add_response.rbi
|
|
144
149
|
- rbi/safety_kit/models/data_create_upload_url_params.rbi
|
|
@@ -165,6 +170,7 @@ files:
|
|
|
165
170
|
- rbi/safety_kit/resources/beta.rbi
|
|
166
171
|
- rbi/safety_kit/resources/beta/events.rbi
|
|
167
172
|
- rbi/safety_kit/resources/client_sessions.rbi
|
|
173
|
+
- rbi/safety_kit/resources/content.rbi
|
|
168
174
|
- rbi/safety_kit/resources/data.rbi
|
|
169
175
|
- rbi/safety_kit/resources/deletion_requests.rbi
|
|
170
176
|
- rbi/safety_kit/resources/streams.rbi
|
|
@@ -198,6 +204,8 @@ files:
|
|
|
198
204
|
- sig/safety_kit/models/beta/event_create_response.rbs
|
|
199
205
|
- sig/safety_kit/models/client_session_create_session_params.rbs
|
|
200
206
|
- sig/safety_kit/models/client_session_create_session_response.rbs
|
|
207
|
+
- sig/safety_kit/models/content_create_params.rbs
|
|
208
|
+
- sig/safety_kit/models/content_create_response.rbs
|
|
201
209
|
- sig/safety_kit/models/data_add_params.rbs
|
|
202
210
|
- sig/safety_kit/models/data_add_response.rbs
|
|
203
211
|
- sig/safety_kit/models/data_create_upload_url_params.rbs
|
|
@@ -224,6 +232,7 @@ files:
|
|
|
224
232
|
- sig/safety_kit/resources/beta.rbs
|
|
225
233
|
- sig/safety_kit/resources/beta/events.rbs
|
|
226
234
|
- sig/safety_kit/resources/client_sessions.rbs
|
|
235
|
+
- sig/safety_kit/resources/content.rbs
|
|
227
236
|
- sig/safety_kit/resources/data.rbs
|
|
228
237
|
- sig/safety_kit/resources/deletion_requests.rbs
|
|
229
238
|
- sig/safety_kit/resources/streams.rbs
|