-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
60 lines (49 loc) · 2.18 KB
/
main.py
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
import asyncio
import logging
import os
from autogen_core import EVENT_LOGGER_NAME, AgentId, AgentProxy, SingleThreadedAgentRuntime
from autogen_magentic_one.agents.orchestrator import LedgerOrchestrator
from autogen_magentic_one.utils import LogHandler, create_completion_client_from_env
from agents.research_agent import ResearchAgent
from agents.underwriting_agent import UnderwritingAgent
from agents.sales_agent import SalesAgent
from runtime.orchestrator import InsuranceOrchestrator
async def main(logs_dir: str) -> None:
# Ustvarimo runtime
runtime = SingleThreadedAgentRuntime()
# Ustvarimo client za LLM
client = create_completion_client_from_env(model="gpt-4")
# Registriramo agente
await ResearchAgent.register(runtime, "ResearchAgent",
lambda: ResearchAgent(model_client=client))
research = AgentProxy(AgentId("ResearchAgent", "default"), runtime)
await UnderwritingAgent.register(runtime, "UnderwritingAgent",
lambda: UnderwritingAgent(model_client=client))
underwriting = AgentProxy(AgentId("UnderwritingAgent", "default"), runtime)
await SalesAgent.register(runtime, "SalesAgent",
lambda: SalesAgent(model_client=client))
sales = AgentProxy(AgentId("SalesAgent", "default"), runtime)
agent_list = [research, underwriting, sales]
# Registriramo orchestrator
await InsuranceOrchestrator.register(
runtime,
"Orchestrator",
lambda: InsuranceOrchestrator(
agents=agent_list,
model_client=client,
max_rounds=30,
max_time=25 * 60,
return_final_answer=True,
)
)
runtime.start()
await runtime.stop_when_idle()
if __name__ == "__main__":
logs_dir = "logs"
if not os.path.exists(logs_dir):
os.makedirs(logs_dir)
logger = logging.getLogger(EVENT_LOGGER_NAME)
logger.setLevel(logging.INFO)
log_handler = LogHandler(filename=os.path.join(logs_dir, "insurance_log.jsonl"))
logger.handlers = [log_handler]
asyncio.run(main(logs_dir))