pub trait OutputGuardrail: WasmCompatSend + WasmCompatSync {
// Required method
fn check(
&self,
output: &str,
) -> impl Future<Output = GuardrailResult> + WasmCompatSend;
}Expand description
Guardrail that checks output before it reaches the user.
§Example
ⓘ
use neuron_runtime::*;
struct NoLeakedSecrets;
impl OutputGuardrail for NoLeakedSecrets {
fn check(&self, output: &str) -> impl Future<Output = GuardrailResult> + Send {
async move {
if output.contains("sk-") {
GuardrailResult::Tripwire("Output contains secret key".to_string())
} else {
GuardrailResult::Pass
}
}
}
}Required Methods§
Sourcefn check(
&self,
output: &str,
) -> impl Future<Output = GuardrailResult> + WasmCompatSend
fn check( &self, output: &str, ) -> impl Future<Output = GuardrailResult> + WasmCompatSend
Check the output text and return a guardrail result.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.