-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodes.py
More file actions
76 lines (60 loc) · 2.83 KB
/
nodes.py
File metadata and controls
76 lines (60 loc) · 2.83 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from agents import jury_agents, judge_agent, JuryOutput, JudgeOutput, State
from prompts import JURY_1_PROMPT, JURY_2_PROMPT, JURY_3_PROMPT, JUDGE_PROMPT
def jury_1_node(state: State) -> dict:
messages = jury_agents.context_input(JURY_1_PROMPT, state)
result = jury_agents.agent.invoke({"messages": messages})
response = result["structured_response"]
return {"agent_history": [{"round": state["current_round"],
"agent_name": "Jury 1 (Resmi/Tarihi Kaynaklar)",
"thesis": response.thesis,
"counter_thesis": response.counter_thesis,
"counter_reasoning": response.counter_reasoning,
"reasoning": response.reasoning,
"sources": response.sources}]}
def jury_2_node(state: State) -> dict:
messages = jury_agents.context_input(JURY_2_PROMPT, state)
result = jury_agents.agent.invoke({"messages": messages})
response = result["structured_response"]
return {"agent_history": [{"round": state["current_round"],
"agent_name": "Jury 2 (Kamuoyu/Sosyal Medya)",
"thesis": response.thesis,
"counter_thesis": response.counter_thesis,
"counter_reasoning": response.counter_reasoning,
"reasoning": response.reasoning,
"sources": response.sources}]}
def jury_3_node(state: State) -> dict:
messages = jury_agents.context_input(JURY_3_PROMPT, state)
result = jury_agents.agent.invoke({"messages": messages})
response = result["structured_response"]
return {"agent_history": [{"round": state["current_round"],
"agent_name": "Jury 3 (Akademik/Bilimsel Veriler)",
"thesis": response.thesis,
"counter_thesis": response.counter_thesis,
"counter_reasoning": response.counter_reasoning,
"reasoning": response.reasoning,
"sources": response.sources}]}
def judge_node(state: State) -> dict:
messages = judge_agent.context_input(JUDGE_PROMPT, state)
result = judge_agent.agent.invoke({"messages": messages})
response = result["structured_response"]
return {"judge_output": {
"thesis": response.thesis,
"reasoning": response.reasoning,
"jury_1_score": response.jury_1_score,
"jury_1_reason": response.jury_1_reason,
"jury_2_score": response.jury_2_score,
"jury_2_reason": response.jury_2_reason,
"jury_3_score": response.jury_3_score,
"jury_3_reason": response.jury_3_reason,
"final_response": response.final_response,
"sources": response.sources
}}
def dispatch_node(state: State) -> dict:
return {}
def round_check_node(state: State) -> dict:
return {"current_round": state["current_round"] + 1}
def should_continue(state: State) -> str:
if state["current_round"] < 3:
return "continue"
else:
return "judge"