(&self, messages: &[Json], response_text: &str)
| 201 | } |
| 202 | |
| 203 | async fn check_output_rails(&self, messages: &[Json], response_text: &str) -> FlowResult<()> { |
| 204 | let mut output_messages = messages.to_vec(); |
| 205 | output_messages.push(json!({ |
| 206 | "role": "assistant", |
| 207 | "content": response_text, |
| 208 | })); |
| 209 | |
| 210 | match self |
| 211 | .bridge |
| 212 | .check(output_messages, LocalRailKind::Output) |
| 213 | .await? |
| 214 | { |
| 215 | LocalCheckOutcome::Passed => Ok(()), |
| 216 | LocalCheckOutcome::Blocked { rail, .. } => { |
| 217 | Err(blocked_error("output", rail.as_deref())) |
| 218 | } |
| 219 | LocalCheckOutcome::Modified { .. } => Err(local_violation( |
| 220 | "NeMo Guardrails output rail returned modified content, but the local backend \ |
| 221 | does not rewrite provider responses yet.", |
| 222 | )), |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | async fn check_tool_input(&self, tool_name: &str, args: &Json) -> FlowResult<Json> { |
| 227 | let messages = vec![json!({ |
no test coverage detected