Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
Hello, I am new to crewai and excited about its potential. I used the "Chat with our docs" interface to create a first crew for retrieving market segments from a companies' websites, but when I execute the code it gets stuck. What could be the issue?
Here is the code I've used:
import os
import argparse
from crewai import Agent, Task, Crew, Process
from crewai_tools import ScrapeWebsiteTool
from langchain_ollama.llms import OllamaLLM
def main(website_url):
# Set environment variables for API keys if needed
# os.environ["OPENAI_API_KEY"] = "Your-OpenAI-API-Key"
# Initialize the Ollama client for the local Mistral model
llm = OllamaLLM(model="mistral")
# Define the tools
scrape_tool = ScrapeWebsiteTool(website_url)
# Define the Website Scraper Agent
scraper_agent = Agent(
role='Website Scraper',
goal='Retrieve information from the given website',
backstory='You are skilled at extracting and processing information from websites.',
tools=[scrape_tool],
llm=llm, # Assign the Mistral LLM to the agent
verbose=True
)
# Define the Market Research Analyst Agent
market_analyst_agent = Agent(
role='Market Research Analyst',
goal='Analyze the information retrieved from the website to identify market segments.',
backstory='With your expertise in market analysis, you can identify key market segments from textual data.',
llm=llm, # Assign the Mistral LLM to the agent
verbose=True
)
# Define the Scrape Website Task
scrape_website_task = Task(
description=(
"Retrieve the content from the specified website URL. "
"Ensure the data is clean and well-formatted for further analysis."
),
expected_output='A text file containing the raw content from the website.',
agent=scraper_agent,
tools=[scrape_tool]
)
# Define the Analyze Market Segments Task
analyze_market_segments_task = Task(
description=(
"Analyze the content retrieved from the website to identify and summarize "
"the market segments represented in the text."
),
expected_output='A report identifying and summarizing the key market segments in a text file.',
agent=market_analyst_agent
)
# Define the crew
market_research_crew = Crew(
agents=[scraper_agent, market_analyst_agent],
tasks=[scrape_website_task, analyze_market_segments_task],
process=Process.sequential
)
# Execute the crew with the website URL as input
result = market_research_crew.kickoff(inputs={'website_url': website_url})
print(result)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Market Research Crew")
parser.add_argument(
"website_url",
type=str,
help="The URL of the website to scrape and analyze"
)
args = parser.parse_args()
main(args.website_url)
Hello, I am new to crewai and excited about its potential. I used the "Chat with our docs" interface to create a first crew for retrieving market segments from a companies' websites, but when I execute the code it gets stuck. What could be the issue?
Here is the code I've used: