Repository navigation
Expand file tree
/
Copy pathchat.py
More file actions
87 lines (64 loc) · 4.22 KB
/
Copy pathchat.py
File metadata and controls
87 lines (64 loc) · 4.22 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
import asyncio
import json
from pathlib import Path
from core.orchestrator_main import OrchestratorAgent
# Optional session file path
SESSION_DIR = Path("sessions")
SESSION_DIR.mkdir(exist_ok=True)
SESSION_FILE = Path("sessions/history.json")
class ChatSession:
"""Handles multi-participant chat messages and optional serialization."""
def __init__(self):
self.messages = [] # list of dicts: {role, content}
def add_message(self, role: str, content: str):
self.messages.append({"role": role, "content": content})
def save(self, path: Path = SESSION_FILE):
path.parent.mkdir(exist_ok=True) # create folder if missing
with open(path, "w", encoding="utf-8") as f:
json.dump(self.messages, f, indent=2, ensure_ascii=False)
print(f"[ChatSession] Saved {len(self.messages)} messages to {path}")
async def chat():
orchestrator = OrchestratorAgent()
session = ChatSession()
print("Agentic AI System Ready. Type 'exit' to quit.\n")
print('''
▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄
▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄
▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄
▄▄▄▄ ▄▄▄▄ ▄▄▄▄▄
▄██▀▀██▄ ██ ▀▀ ▄██▀▀██▄ ███
███ ███ ▄████ ▄█▀█▄ ████▄ ▀██▀▀ ██ ▄████ ███ ███ ███
███▀▀███ ██ ██ ██▄█▀ ██ ██ ██ ██ ██ ███▀▀███ ███
███ ███ ▀████ ▀█▄▄▄ ██ ██ ██ ██▄ ▀████ ███ ███ ▄███▄
██
▀▀▀
▄▄▄▄▄▄▄ ▄▄
███▀▀███▄ ██
███▄▄███▀ ▄█▀█▄ ▄█▀▀▀ ▄█▀█▄ ▀▀█▄ ████▄ ▄████ ████▄ ▄█▀█▄ ████▄
███▀▀██▄ ██▄█▀ ▀███▄ ██▄█▀ ▄█▀██ ██ ▀▀ ██ ██ ██ ██▄█▀ ██ ▀▀
███ ▀███ ▀█▄▄▄ ▄▄▄█▀ ▀█▄▄▄ ▀█▄██ ██ ▀████ ██ ██ ▀█▄▄▄ ██
▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄ ▄
▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄ ▄███▄
▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄ ▄▀█▀▄
''')
print(
"Hello! What would you like me to do today?\n"
"Features: research summary, deployment to latex, both, or other.\n"
"You can also type 'exit' to quit.\n"
)
while True:
user_input = input("Provide input or type exit > ").strip()
if user_input.lower() == "exit":
print("Exiting Agentic AI System.")
break
# Add user message
session.add_message("user", user_input)
# Agent response
response = await orchestrator.handle_user_message(user_input)
agent_content = response["content"]
print("Agent >", agent_content, "\n")
session.add_message("agent", agent_content)
# Save session after each message (optional, can be commented)
session.save()
if __name__ == "__main__":
asyncio.run(chat())