-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
80 lines (72 loc) · 1.93 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
import os
from rich import print
from crewai import Agent, Task, Crew
from dotenv import load_dotenv
from src.config import (
log_researcher,
log_writer,
log_prompt_master,
log_crew,
llm_model_name,
planning_llm_name,
)
from src.tools import search_tool
from src.llm import LLMFactory
from src.agents import (
ResearcherAgent,
WriterAgent,
PromptMasterAgent,
create_tasks,
)
import subprocess
# Load environment variables
load_dotenv()
def create_crew():
try:
researcher = ResearcherAgent(search_tool=search_tool)
writer = WriterAgent()
prompt_master = PromptMasterAgent()
tasks = create_tasks(researcher, writer, prompt_master)
return Crew(
agents=[researcher, writer, prompt_master],
tasks=tasks,
verbose=True,
planning=True,
planning_llm=LLMFactory.init_planning_llm(),
output_log_file=log_crew
)
except Exception as e:
print(f"Error creating crew: {str(e)}")
raise
def main():
try:
# Ensure the log directory exists
log_directory = os.path.dirname(log_crew)
if not os.path.exists(log_directory):
os.makedirs(log_directory)
print(
f"""
-------------------
LLM Models:
- llm_model_name = {llm_model_name}
- planning_llm_name = {planning_llm_name}
-------------------
"""
)
crew = create_crew()
crew.kickoff()
print(
f"""
-------------------
JOB DONE!
- llm_model_name = {llm_model_name}
- planning_llm_name = {planning_llm_name}
-------------------
"""
)
except Exception as e:
print(f"Error running application: {str(e)}")
raise
if __name__ == "__main__":
main()