Closed LukeLalor closed 5 days ago
Thanks for the feedback. We're updating the site with a working example.
For your code above try using this modified code which should work.
Just make sure to add your OPENAI_API_KEY
and SERPER_API_KEY
to your .env
file in root.
from crewai import Agent, Task, Crew, Process, LLM
from crewai_tools import SerperDevTool
import os
llm = LLM(
model="gpt-4o",
temperature=0.5,
api_key=os.environ.get("OPENAI_API_KEY")
)
# Agent definition
researcher = Agent(
role='{topic} Senior Researcher',
goal='Uncover groundbreaking technologies in {topic} for year 2024',
backstory='Driven by curiosity, you explore and share the latest innovations.',
tools=[SerperDevTool()],
llm=llm
)
# Define a research task for the Senior Researcher agent
research_task = Task(
description='Identify the next big trend in {topic} with pros and cons.',
expected_output='A 3-paragraph report on emerging {topic} technologies.',
agent=researcher
)
def main():
# Forming the crew and kicking off the process
crew = Crew(
agents=[researcher],
tasks=[research_task],
process=Process.sequential,
verbose=True
)
result = crew.kickoff(inputs={'topic': 'AI Agents'})
print(result)
if __name__ == "__main__":
main()
Description
The example on https://www.crewai.com/open-source does not work. To be clear, the error is just a pydantic error meaning the example is likely out of date and just needs to be updated.
I am not asking how to make this example work, just pointing out that the example provided is broken.
python 3.12.4 crew 0.67.1
Combine this into a single example
and you get an error
Steps to Reproduce
poetry new testcrew
poetry add crewai
vim testcrew script.py
<- add example from descriptionpoetry run python crewtest/script.py
Expected behavior
Expected: It to work Actual:
Screenshots/Code snippets
Operating System
Sonoma 14.6.1
Python Version
3.12.4
crewAI Version
0.67.1
crewAI Tools Version
n/a
Virtual Environment
Poetry
Evidence
Possible Solution
update the example with correct contract
Additional context
I am just pointing out that the example on the front page doesn't work, not necessarily trying to get this to work.