Class: SafetyKit::Resources::Content

Inherits:
Object
  • Object
show all
Defined in:
lib/safety_kit/resources/content.rb,
sig/safety_kit/resources/content.rbs

Overview

Classify user-authored text and images synchronously and receive a decision in the response.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Content

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Content.

Parameters:



47
48
49
# File 'lib/safety_kit/resources/content.rb', line 47

def initialize(client:)
  @client = client
end

Instance Method Details

#create(entity_id:, content_id: nil, images: nil, metadata: nil, text: nil, request_options: {}) ⇒ SafetyKit::Models::ContentCreateResponse

Some parameter documentations has been truncated, see Models::ContentCreateParams for more details.

Classify a piece of content synchronously. Send user-authored text, images, or both, and receive a decision (approve, reject, or review) with classifier scores and reference set matches in the response. The full request body must stay under 6MB, which allows roughly 4.4MB of raw image bytes after base64 inflation.

Parameters:

  • entity_id (String)

    Your stable identifier for the entity this content belongs to, such as a user, l

  • content_id (String)

    Your identifier for this piece of content — the same content_id you send on /v1/

  • images (Array<String>)

    Images to classify, each as base64-encoded image bytes, raw or as a data URI. At

  • metadata (Hash{Symbol=>Object, nil})

    Additional product context for this content. At most 8KB when serialized.

  • text (String)

    User-authored text to classify. At most 20000 characters.

  • request_options (SafetyKit::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



33
34
35
36
37
38
39
40
41
42
# File 'lib/safety_kit/resources/content.rb', line 33

def create(params)
  parsed, options = SafetyKit::ContentCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/content",
    body: parsed,
    model: SafetyKit::Models::ContentCreateResponse,
    options: options
  )
end