Class: Pangea::Services::AiGuard
- Inherits:
-
Object
- Object
- Pangea::Services::AiGuard
- Defined in:
- lib/pangea/services/ai_guard.rb
Instance Method Summary collapse
-
#guard_text(params) ⇒ Pangea::Models::PangeaResponse<Pangea::Models::AiGuard::TextGuardResult>
Analyze and redact text to avoid manipulation of the model, addition of malicious content, and other undesirable data transfers.
-
#initialize(api_token: nil, base_url: nil, domain: nil) ⇒ AiGuard
constructor
Creates and returns a new client for interacting with the Pangea AI Guard API.
Constructor Details
#initialize(api_token: nil, base_url: nil, domain: nil) ⇒ AiGuard
Creates and returns a new client for interacting with the Pangea AI Guard API.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pangea/services/ai_guard.rb', line 12 def initialize( api_token: nil, base_url: nil, domain: nil ) if !base_url && domain base_url = "https://ai-guard.#{domain}" end base_url ||= "https://ai-guard.aws.us.pangea.cloud" @client = Pangea::Client.new(api_token: api_token, base_url: base_url) end |
Instance Method Details
#guard_text(text: , recipe: , debug: , request_options: {}) ⇒ Pangea::Models::PangeaResponse<Pangea::Models::AiGuard::TextGuardResult> #guard_text(messages: , recipe: , debug: , request_options: {}) ⇒ Pangea::Models::PangeaResponse<Pangea::Models::AiGuard::TextGuardResult>
Analyze and redact text to avoid manipulation of the model, addition of malicious content, and other undesirable data transfers.
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pangea/services/ai_guard.rb', line 49 def guard_text(params) parsed, = Pangea::Models::AiGuard::TextGuardParams.dump_request(params) @client.request( method: :post, path: "v1/text/guard", body: parsed, structure: Pangea::Models::PangeaResponse, model: Pangea::Models::AiGuard::TextGuardResult, options: ) end |