pub trait InputGuardrail: WasmCompatSend + WasmCompatSync {
// Required method
fn check(
&self,
input: &str,
) -> impl Future<Output = GuardrailResult> + WasmCompatSend;
}Expand description
Guardrail that checks input before it reaches the LLM.
§Example
ⓘ
use neuron_runtime::*;
struct NoSecrets;
impl InputGuardrail for NoSecrets {
fn check(&self, input: &str) -> impl Future<Output = GuardrailResult> + Send {
async move {
if input.contains("API_KEY") {
GuardrailResult::Tripwire("Input contains API key".to_string())
} else {
GuardrailResult::Pass
}
}
}
}Required Methods§
Sourcefn check(
&self,
input: &str,
) -> impl Future<Output = GuardrailResult> + WasmCompatSend
fn check( &self, input: &str, ) -> impl Future<Output = GuardrailResult> + WasmCompatSend
Check the input 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.