-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (39 loc) · 1.3 KB
/
main.py
File metadata and controls
46 lines (39 loc) · 1.3 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
import os
from dotenv import load_dotenv
from crewai import Crew
from crew.agents import ResearchAgents
from crew.tasks import ResearchTasks
from tools.search_tools import SearchTools
load_dotenv()
class PerplexityClone:
def __init__(self):
self.search_tools = SearchTools()
self.agents = ResearchAgents()
self.tasks = ResearchTasks()
def query(self, prompt):
# Initialize agents
search_agent = self.agents.search_specialist()
analysis_agent = self.agents.research_analyst()
# Create tasks
search_task = self.tasks.web_search_task(search_agent, prompt)
analysis_task = self.tasks.analysis_task(analysis_agent, prompt)
# Set up crew
crew = Crew(
agents=[search_agent, analysis_agent],
tasks=[search_task, analysis_task],
verbose=True,
memory=True,
)
# Execute workflow
result = crew.kickoff()
return result
if __name__ == "__main__":
app = PerplexityClone()
print("Perplexity Clone - Research Assistant")
while True:
query = input("\nEnter your query (or 'exit' to quit): ")
if query.lower() == 'exit':
break
response = app.query(query)
print("\n\n=== Research Results ===")
print(response)