-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnexus.py
More file actions
76 lines (65 loc) · 2.07 KB
/
nexus.py
File metadata and controls
76 lines (65 loc) · 2.07 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
# imports
import os
from langchain_groq import ChatGroq
from langchain_community.tools import DuckDuckGoSearchRun
from crewai import Agent, Task, Crew, Process, LLM
from crewai.tools import BaseTool
# configuration
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
if not GROQ_API_KEY:
raise ValueError("Please set the GROQ_API_KEY environment variable")
MY_LLM = LLM(
model='groq/llama-3.3-70b-versatile',
api_key=GROQ_API_KEY,
)
# MY_LLM = ChatGroq(
# groq_api_key=GROQ_API_KEY,
# model="llama3-70b-8192"
# )
# define a custom tool
class SearchTool(BaseTool):
name: str = "search"
description: str = "Useful for searching the internet about 2025 and 2026 tech trends."
def _run(self, query: str) -> str:
try:
return DuckDuckGoSearchRun().run(query)
except Exception as e:
return f"Search failed: {e}"
search_tool = SearchTool()
# define agents
researcher = Agent(
role="Tech trends analyst",
goal="Identify the 5 most significant tech breakthroughs of 2025",
backstory="You are an expert tech journalist with an eye for industry-shifting tech.",
tools=[search_tool],
llm=MY_LLM,
max_iter=3,
verbose=True
)
strategist = Agent(
role="Career Success Architect",
goal="Create a 2026 learning roadmap based on 2025 trends",
backstory="You are a senior engineering manager who knows how to stay relevant.",
llm=MY_LLM,
max_iter=3,
verbose=True
)
# tasks
task1 = Task(
description="Research 2025 tech trends in AI and software industry",
expected_output='A list of top 5 breakthroughs with a brief explanation of why they matter.',
agent=researcher
)
task2 = Task(
description="Based on the research provided, create a 3-month roadmap for a dev to master these skills in Q1 2026.",
expected_output='A month-by-month learning plan with specific topics and project ideas.',
agent=strategist
)
# Assemble the crew
nexus_crew = Crew(
agents=[researcher, strategist],
tasks=[task1, task2],
process=Process.sequential
)
result = nexus_crew.kickoff()
print(result)