-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph_states.py
More file actions
138 lines (113 loc) · 4.44 KB
/
graph_states.py
File metadata and controls
138 lines (113 loc) · 4.44 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
from pydantic import BaseModel, Field
from typing import TypedDict, List, Annotated
from langchain_core.messages import BaseMessage
from langgraph.graph import MessagesState
from langchain.agents import AgentState
import operator
from enum import Enum
# ------------ RESEARCH GRAPH --------------
class Queries(BaseModel):
queries: list[str] = Field(..., max_length=5,description="The list of queries generated by user query to search on different sources")
class Extractor(BaseModel):
query_understanding: str
extracted_information: list[str]
missing_information: list[str]
class Analyzer(BaseModel):
query_statisfied: bool
reasoning: str
query: str
missing_or_uncertain_information: list[str]
class DataExtractionState(TypedDict):
query:str
subqueries:list[str]
subquery_extracted_data:list[str] | None
subquery_reviews:list[Analyzer]
results:list[str]
vector_store:str
query_limit:int
# ------------ END RESEARCH GRAPH --------------
# ------------ FORUM MODEL --------------
class Persona(BaseModel):
persona_name:str = Field(..., description="The name of the persona")
persona_prompt:str = Field(..., description="The prompt of the persona")
class Agent_Persona_Generator(BaseModel):
agent_1:Persona = Field(..., description="The first persona")
agent_2:Persona = Field(..., description="The second persona")
class SupervisorState(AgentState):
vector_store:str
class DebateState(BaseModel):
debate_topic: str = Field(
description="The original debate topic"
)
agent_a_position: str = Field(
description="Summary of Proponent's core stance and key evidence so far"
)
agent_b_position: str = Field(
description="Summary of Opponent's core stance and key evidence so far"
)
key_clashes: List[str] = Field(
description="Specific points where agents strongly disagreed"
)
agreed_points: List[str] = Field(
description="Points where agents reached consensus, if any"
)
immediate_context: str = Field(
description="The very last thing that happened in the debate"
)
class NodeType(str, Enum):
CLAIM = "claim" # The main point
EVIDENCE = "evidence" # Data/Stats supporting a claim
ATTACK = "attack" # A direct rebuttal
class LogicNode(BaseModel):
id: str = Field(description="A short, unique variable name (e.g., 'cost_argument'). Do NOT use prefixes like R1_.")
label: str = Field(description="Max 5 words summary of the point.")
type: NodeType
class LogicEdge(BaseModel):
source_id: str
target_id: str
relationship: str = Field(description="Short verb describing the link, e.g., 'supports', 'refutes', 'weakens'.")
class RoundDigest(BaseModel):
round_number: int
winner_of_round: str = Field(description="Who had the stronger argument? 'Agent A', 'Agent B', or 'Draw'")
winner_rationale: str = Field(description="One sentence explaining WHY they won.")
key_arguments_pro: List[str]
key_arguments_con: List[str]
# Instead of raw string, we ask for structured graph data
graph_nodes: List[LogicNode] = Field(description="The key logical entities in this round.")
graph_edges: List[LogicEdge] = Field(description="How the entities connect.")
class FinalReport(BaseModel):
title: str
executive_summary: str = Field(description="High-level overview of the debate outcome")
key_arguments_agent_1: list[str]
key_arguments_agent_2: list[str]
consensus_points: list[str]
unique_perspectives: list[str]
class ForumState(MessagesState):
query:str
summary:str
max_rounds:int
current_round:int
agent_1:Persona
agent_2:Persona
vector_store:str
round_digests: Annotated[list[RoundDigest],operator.add]
running_mermaid_graph: Annotated[str,operator.add]
debate_history: Annotated[list[BaseMessage],operator.add]
final_report: FinalReport | None
references: Annotated[list[list[str]],operator.add]
step:int
# ------------ END FORUM MODEL --------------
# ------------ Final Graph -------------------
class FinalState(MessagesState):
query:str
vector_store:str
query_limit:int
max_rounds:int
current_round:int
step:int
round_digests: Annotated[list[RoundDigest],operator.add]
running_mermaid_graph: Annotated[str,operator.add]
debate_history: Annotated[list[BaseMessage],operator.add]
references: Annotated[list[list[str]],operator.add]
final_report: FinalReport | None
# ------------ END Final Graph --------------