-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouting.py
More file actions
37 lines (26 loc) · 932 Bytes
/
routing.py
File metadata and controls
37 lines (26 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Conditional routing functions for the LangGraph agent."""
from app.agents.state import AgentState
def route_after_guard_inicial(state: AgentState) -> str:
"""
Route after Guard Inicial node validation.
Determines the next step based on whether the prompt was flagged as malicious.
Args:
state: Current agent state
Returns:
"malicious" if the prompt is malicious, "continue" otherwise
"""
if state.get("is_malicious", False):
return "malicious"
return "continue"
def route_after_guard_final(state: AgentState) -> str:
"""
Route after Guard Final node validation.
Determines the next step based on whether the response was flagged as risky.
Args:
state: Current agent state
Returns:
"risky" if the response is risky, "continue" otherwise
"""
if state.get("is_risky", False):
return "risky"
return "continue"