-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy pathstate.py
More file actions
58 lines (39 loc) · 1.27 KB
/
state.py
File metadata and controls
58 lines (39 loc) · 1.27 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
from __future__ import annotations
from dataclasses import dataclass, field
from typing import TypedDict
from langgraph.graph import add_messages
from typing_extensions import Annotated
import operator
class TokenUsageRecord(TypedDict):
"""Record of token usage for a single node execution."""
node_name: str
input_tokens: int
output_tokens: int
model: str
class OverallState(TypedDict):
messages: Annotated[list, add_messages]
search_query: Annotated[list, operator.add]
web_research_result: Annotated[list, operator.add]
sources_gathered: Annotated[list, operator.add]
token_usage_records: Annotated[list, operator.add]
initial_search_query_count: int
max_research_loops: int
research_loop_count: int
reasoning_model: str
class ReflectionState(TypedDict):
is_sufficient: bool
knowledge_gap: str
follow_up_queries: Annotated[list, operator.add]
research_loop_count: int
number_of_ran_queries: int
class Query(TypedDict):
query: str
rationale: str
class QueryGenerationState(TypedDict):
search_query: list[Query]
class WebSearchState(TypedDict):
search_query: str
id: str
@dataclass(kw_only=True)
class SearchStateOutput:
running_summary: str = field(default=None) # Final report