Skip to content

Commit cc2c33f

Browse files
authored
Refactor safety response handling in guardrails.mdx
1 parent 6a59921 commit cc2c33f

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/oss/langchain/guardrails.mdx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -484,13 +484,7 @@ class SafetyGuardrailMiddleware(AgentMiddleware):
484484
result = self.safety_model.invoke([{"role": "user", "content": safety_prompt}])
485485

486486
if "UNSAFE" in result.content:
487-
return {
488-
"messages": [{
489-
"role": "assistant",
490-
"content": "I cannot provide that response. Please rephrase your request."
491-
}],
492-
"jump_to": "end"
493-
}
487+
last_message.content = "I cannot provide that response. Please rephrase your request."
494488

495489
return None
496490

0 commit comments

Comments
 (0)