Class: Riffer::Guardrail
- Inherits:
-
Object
- Object
- Riffer::Guardrail
- Defined in:
- lib/riffer/guardrail.rb
Overview
Base class for guardrails that process input and output in the agent pipeline.
Subclass this to create custom guardrails:
class MyGuardrail < Riffer::Guardrail
def process_input(, context:)
# Return pass(messages), transform(modified_messages), or block(reason)
pass()
end
def process_output(response, messages:, context:)
# Return pass(response), transform(modified_response), or block(reason)
pass(response)
end
end
Instance Method Summary collapse
-
#process_input(messages, context:) ⇒ Object
Processes input messages before they are sent to the LLM.
-
#process_output(response, messages:, context:) ⇒ Object
Processes output response after it is received from the LLM.
Instance Method Details
#process_input(messages, context:) ⇒ Object
Processes input messages before they are sent to the LLM.
Override this method in subclasses to implement input processing.
- messages
-
the input messages.
- context
-
optional context passed to the agent.
– : (Array, context: untyped) -> Riffer::Guardrails::Result
29 30 31 |
# File 'lib/riffer/guardrail.rb', line 29 def process_input(, context:) pass() end |
#process_output(response, messages:, context:) ⇒ Object
Processes output response after it is received from the LLM.
Override this method in subclasses to implement output processing.
- response
-
the LLM response.
- messages
-
the conversation messages.
- context
-
optional context passed to the agent.
– : (Riffer::Messages::Assistant, messages: Array, context: untyped) -> Riffer::Guardrails::Result
43 44 45 |
# File 'lib/riffer/guardrail.rb', line 43 def process_output(response, messages:, context:) pass(response) end |