Class: Riffer::Agent::Response
- Inherits:
-
Object
- Object
- Riffer::Agent::Response
- Defined in:
- lib/riffer/agent/response.rb
Overview
Wraps agent generation responses with optional tripwire information.
When guardrails block execution, the response will contain a tripwire with details about the block. The content will be empty for blocked responses.
response = agent.generate("Hello")
if response.blocked?
puts "Blocked: #{response.tripwire.reason}"
else
puts response.content
end
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
The response content.
-
#modifications ⇒ Object
readonly
The modifications made by guardrails during processing.
-
#tripwire ⇒ Object
readonly
The tripwire if execution was blocked.
Instance Method Summary collapse
-
#blocked? ⇒ Boolean
Returns true if the response was blocked by a guardrail.
-
#initialize(content, tripwire: nil, modifications: []) ⇒ Response
constructor
Creates a new response.
-
#modified? ⇒ Boolean
Returns true if any guardrail modified data during processing.
Constructor Details
#initialize(content, tripwire: nil, modifications: []) ⇒ Response
Creates a new response.
content - the response content. tripwire - optional tripwire for blocked responses. modifications - guardrail modifications applied during processing.
: (String, ?tripwire: Riffer::Guardrails::Tripwire?, ?modifications: Array) -> void
32 33 34 35 36 |
# File 'lib/riffer/agent/response.rb', line 32 def initialize(content, tripwire: nil, modifications: []) @content = content @tripwire = tripwire @modifications = modifications end |
Instance Attribute Details
#content ⇒ Object (readonly)
The response content.
17 18 19 |
# File 'lib/riffer/agent/response.rb', line 17 def content @content end |
#modifications ⇒ Object (readonly)
The modifications made by guardrails during processing.
23 24 25 |
# File 'lib/riffer/agent/response.rb', line 23 def modifications @modifications end |
#tripwire ⇒ Object (readonly)
The tripwire if execution was blocked.
20 21 22 |
# File 'lib/riffer/agent/response.rb', line 20 def tripwire @tripwire end |
Instance Method Details
#blocked? ⇒ Boolean
Returns true if the response was blocked by a guardrail.
: () -> bool
41 42 43 |
# File 'lib/riffer/agent/response.rb', line 41 def blocked? !tripwire.nil? end |
#modified? ⇒ Boolean
Returns true if any guardrail modified data during processing.
: () -> bool
48 49 50 |
# File 'lib/riffer/agent/response.rb', line 48 def modified? modifications.any? end |