Class: Datadog::AIGuard::Contrib::RubyLLM::RedactionChangeSet Private
- Inherits:
-
Object
- Object
- Datadog::AIGuard::Contrib::RubyLLM::RedactionChangeSet
- Defined in:
- lib/datadog/ai_guard/contrib/ruby_llm/redaction_change_set.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Changes required to redact a RubyLLM message
Instance Method Summary collapse
- #apply_to(message) ⇒ Object private
-
#initialize(original_message, redacted_message) ⇒ RedactionChangeSet
constructor
private
A new instance of RedactionChangeSet.
Constructor Details
#initialize(original_message, redacted_message) ⇒ RedactionChangeSet
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 RedactionChangeSet.
14 15 16 17 18 |
# File 'lib/datadog/ai_guard/contrib/ruby_llm/redaction_change_set.rb', line 14 def initialize(, ) @content_replacement = content_replacement(.content, .content) @content_part_replacements = content_part_replacements(.content, .content) @tool_call_replacements = tool_call_replacements(.tool_calls, .tool_calls) end |
Instance Method Details
#apply_to(message) ⇒ Object
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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/datadog/ai_guard/contrib/ruby_llm/redaction_change_set.rb', line 20 def apply_to() return unless changed? # NOTE: Preserve `raw_content` after provider-specific redaction is implemented. # Unchanged raw content could bypass redaction if .raw_content Datadog.logger.warn("AI Guard omitted RubyLLM raw content because it may contain sensitive data") end content = build_content() = () tool_calls = build_tool_calls() = ::RubyLLM::Message.new( content: content, attachments: , tool_calls: tool_calls, role: .role, model: .model, tool_call_id: .tool_call_id, raw: .raw, thinking: .thinking, citations: .citations, finish_reason: .finish_reason, server_tool_calls: .server_tool_calls, raw_reasoning: .raw_reasoning, cache_until_here: .cache_until_here?, ) .conversation = .conversation end |