1- from masfactory import Loop ,NodeTemplate ,HumanFileEditVisual
1+ from masfactory import Loop , NodeTemplate , HumanFileEditVisual
22from .planner_diagnose_loop import PlannerDiagnoseLoop
3- def terminate_check (messages :dict ):
4- user_advice :str = messages .get ("user_advice" ,"" )
5- if len (user_advice .strip ()) == 0 or "agree" in user_advice .lower ():
6- return True
7- else :
8- return False
3+
4+
5+ def terminate_check (messages : dict ) -> bool :
6+ """Stop when user gives no feedback or explicitly agrees."""
7+ user_advice = messages .get ("user_advice" , "" )
8+ if not isinstance (user_advice , str ):
9+ user_advice = str (user_advice )
10+ return (not user_advice .strip ()) or ("agree" in user_advice .lower ())
911
1012PlannerHuman = NodeTemplate (
11- HumanFileEditVisual ,
12- pull_keys = {},
13- push_keys = {},
13+ HumanFileEditVisual ,
14+ pull_keys = {},
15+ push_keys = {},
1416)
1517
16- # PlannerGraph = NodeTemplate(
17- # Loop,
18- # pull_keys={},
19- # push_keys={},
20- # terminate_condition_function=terminate_check,
21- # nodes=[
22- # ("planner",Planner),
23- # ("planner-human",PlannerHuman)
24- # ],
25- # edges=[
26- # ("CONTROLLER","planner",
27- # {
28- # "user_demand":"",
29- # "role_list":"",
30- # "user_advice":"No advice yet."
31- # }
32- # ),
33- # ("planner","planner-human",
34- # {
35- # "graph_design":"The generated graph design accroding to the user's demand and the roles."
36- # }
37- # ),
38- # ("planner","CONTROLLER",
39- # {
40- # "graph_design":"The generated graph design accroding to the user's demand and the roles."
41- # }
42- # ),
43- # ("planner-human","CONTROLLER",
44- # {
45- # "user_advice":"Do you agree the plan? If you agree, enter AGREE. If you have any comments, please enter your comments."
46- # }
47- # )
48- # ]
49- # )
50-
5118PlannerGraph = NodeTemplate (
5219 Loop ,
5320 terminate_condition_function = terminate_check ,
54- pull_keys = {"cache_file_path" :"" },
21+ pull_keys = {"cache_file_path" : "" },
5522 push_keys = {},
56- nodes = [
57- ("planner-diagnose-loop" ,PlannerDiagnoseLoop ),
58- ("planner-human" ,PlannerHuman )
59- ],
23+ nodes = [
24+ ("planner-diagnose-loop" , PlannerDiagnoseLoop ),
25+ ("planner-human" , PlannerHuman ),
26+ ],
6027 edges = [
6128 (
62- "CONTROLLER" ,"planner-diagnose-loop" ,
29+ "CONTROLLER" ,
30+ "planner-diagnose-loop" ,
6331 {
6432 "user_demand" : "User demand" ,
6533 "role_list" : "Role list" ,
66- "user_advice" :"User's feedback"
34+ "user_advice" : "User's feedback" ,
6735 },
6836 ),
6937 (
70- "planner-diagnose-loop" ,"planner-human" ,
38+ "planner-diagnose-loop" ,
39+ "planner-human" ,
7140 {
72- "graph_design" :"The generated graph design accroding to the user's demand and the roles."
41+ "graph_design" : "The generated graph design accroding to the user's demand and the roles."
7342 },
7443 ),
7544 (
76- "planner-human" ,"CONTROLLER" ,
45+ "planner-human" ,
46+ "CONTROLLER" ,
7747 {
78- "user_advice" :"Do you agree the plan? If you agree, enter AGREE. If you have any comments, please enter your comments."
48+ "user_advice" : "Do you agree the plan? If you agree, enter AGREE. If you have any comments, please enter your comments."
7949 }
8050 ),
8151 (
82- "planner-diagnose-loop" ,"CONTROLLER" ,
52+ "planner-diagnose-loop" ,
53+ "CONTROLLER" ,
8354 {
84- "graph_design" :"The generated graph design accroding to the user's demand and the roles."
55+ "graph_design" : "The generated graph design accroding to the user's demand and the roles."
8556 }
86- )
57+ ),
8758 ],
8859)
8960
90- __ALL__ = [
91- ' PlannerGraph'
92- ]
61+ __ALL__ = [
62+ " PlannerGraph" ,
63+ ]
0 commit comments