crewAI
crewAI copied to clipboard
duckduckgo not working as a tool
Here is my environment
Python 3.10.6
crewai 0.19.0
crewai-tools 0.0.15
duckduckgo_search 5.0
I have the following code.
import os
from crewai import Agent, Task, Crew, Process
from langchain_community.llms import Ollama
ollama_llm = Ollama(model="llama2")
from langchain_community.tools import DuckDuckGoSearchRun
from crewai_tools import tool
@tool('DuckDuckGoSearch')
def search(search_query: str):
"""Search the web for information on a given topic"""
return DuckDuckGoSearchRun().run(search_query)
# Define your agents with roles and goals
researcher = Agent(
role='Senior Research Analyst',
goal='Uncover cutting-edge developments in AI and data science',
backstory="""You work at a leading tech think tank.
Your expertise lies in identifying emerging trends.
You have a knack for dissecting complex data and presenting actionable insights.""",
verbose=True,
allow_delegation=False,
tools=[search],
llm=ollama_llm
)
writer = Agent(
role='Tech Content Strategist',
goal='Craft compelling content on tech advancements',
backstory="You are a renowned Content Strategist, known for your insightful and engaging articles.You transform complex concepts into compelling narratives.",
verbose=True,
allow_delegation=True,
llm=ollama_llm
)
# Create tasks for your agents
task1 = Task(
description="Conduct a comprehensive analysis of the latest advancements in AI in 2024.Identify key trends, breakthrough technologies, and potential industry impacts.",
expected_output="Full analysis report in bullet points",
agent=researcher
)
task2 = Task(
description="Using the insights provided, develop an engaging blog post that highlights the most significant AI advancements.Your post should be informative yet accessible, catering to a tech-savvy audience.Make it sound cool, avoid complex words so it doesn't sound like AI.",
expected_output="Full blog post of at least 4 paragraphs",
agent=writer
)
# Instantiate your crew with a sequential process
crew = Crew(
agents=[researcher, writer],
tasks=[task1, task2],
verbose=2, # You can set it to 1 or 2 to different logging levels
)
# Get your crew to work!
result = crew.kickoff()
print("######################")
print(result)
Here is the output
[DEBUG]: Working Agent: Senior Research Analyst
[INFO]: Starting Task: Conduct a comprehensive analysis of the latest advancements in AI in 2024.Identify key trends, breakthrough technologies, and potential industry impacts.
> Entering new CrewAgentExecutor chain...
Thought: I should conduct a thorough search of the latest AI advancements in 2024 to provide a comprehensive analysis of key trends, breakthrough technologies, and potential industry impacts.
Action: DuckDuckGoSearch('latest AI advancements 2024')
Action Input: {'search terms': 'AI', 'date range': '2024'}
Action 'DuckDuckGoSearch('latest AI advancements 2024')' don't exist, these are the only available Actions: DuckDuckGoSearch: DuckDuckGoSearch(search_query: 'string') - Search the web for information on a given topic