-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (45 loc) · 1.7 KB
/
Copy pathmain.py
File metadata and controls
58 lines (45 loc) · 1.7 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
import sys
from pathlib import Path
from langgraph.types import Overwrite
sys.path.append(str(Path(__file__).parent))
from src.agents.graph import app
def run_guru():
print("Welcome to F1-Guru: 2026 Technical Auditor")
print("-" * 40)
config = {"configurable": {"thread_id": "f1_delegate_01"}}
current_summary = ""
while True:
user_input = input("\n[USER]: ")
if user_input.lower() in ["exit", "quit", "q"]:
break
initial_state = {
"query": user_input,
"plan": [],
"tasks_done": 0,
"transformed_query": "",
"summary": current_summary,
"context": Overwrite([]),
"metadatas": Overwrite([]),
"answer": "",
"sources_footer": "",
"grade": "",
"loop_count": 0,
}
for event in app.stream(initial_state, config=config):
for node, state in event.items():
print(f"--- Finished executing: {node} ---")
if node == "cross_reference_node":
fetched_ids = set(
[
m.get("rule_id")
for m in state.get("metadatas", [])
if m.get("rule_id")
]
)
print(f" > Context now contains rules: {list(fetched_ids)}")
final_state = app.get_state(config)
current_summary = final_state.values.get("summary", "")
full_output = f"{final_state.values['answer']}\n{final_state.values.get('sources_footer', '')}"
print(f"\n[GURU]: {full_output}")
if __name__ == "__main__":
run_guru()