File size: 3,660 Bytes
9ccaece 6012040 a008054 a445a3d 810bc36 6012040 51fac14 6012040 a445a3d 534fb78 a445a3d 6012040 a008054 534fb78 a445a3d 51fac14 6012040 534fb78 a445a3d 6012040 a008054 534fb78 a445a3d 51fac14 6012040 534fb78 a445a3d a008054 534fb78 a445a3d 51fac14 6012040 534fb78 a445a3d 534fb78 8370bd2 534fb78 6012040 534fb78 a445a3d 534fb78 8370bd2 534fb78 6012040 534fb78 a445a3d 534fb78 8370bd2 534fb78 6012040 f2149e7 5aaef34 6012040 077dec4 f2149e7 | 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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | from crewai import Agent, Crew, Process, Task
from crewai_tools import SerperDevTool, ScrapeWebsiteTool
from langchain_openai import ChatOpenAI
import streamlit as st
# In agents.py
def create_research_crew(topic: str, questions: list):
tools = [SerperDevTool(), ScrapeWebsiteTool()]
llm = ChatOpenAI(temperature=0.7, model="gpt-4")
researcher = Agent(
role='Market Researcher',
goal=f"""Research the {topic} market comprehensively.
Search for and collect real market data including market size, growth rates, key players, and trends.
Specifically address these questions: {', '.join(questions)}""",
backstory="""Expert market researcher with extensive experience in industry analysis.
Skilled at finding and validating market data from multiple sources.""",
tools=tools,
llm=llm,
max_iterations=2,
verbose=True
)
analyst = Agent(
role='Data Analyst',
goal=f"""Analyze the collected market data for {topic}.
Create insights from the research data.
Ensure to answer: {', '.join(questions)}""",
backstory="Senior data analyst specializing in market trends and competitive analysis",
tools=tools,
llm=llm,
max_iterations=2,
verbose=True
)
writer = Agent(
role='Report Writer',
goal=f"""Create a comprehensive report on {topic} using the research and analysis provided.
Focus on answering: {', '.join(questions)}""",
backstory="Professional report writer with expertise in market research",
llm=llm,
max_iterations=2,
verbose=True
)
tasks = [
Task(
description=f"""Research the {topic} market:
1. Use web search to find current market data
2. Focus on recent market statistics and trends
3. Find information about key players and their market shares
4. Research regional market distribution
5. Look for recent industry developments
6. Address these specific questions: {', '.join(questions)}
Format the research with clear sections for market size, players, trends, and regional analysis.""",
agent=researcher,
expected_output="Detailed market research data"
),
Task(
description=f"""Analyze the research data:
1. Process the market size and growth figures
2. Analyze competitive landscape
3. Identify key trends and patterns
4. Create regional breakdown
5. Address these questions: {', '.join(questions)}
Format the analysis with clear sections and data points.""",
agent=analyst,
expected_output="Market analysis with insights"
),
Task(
description=f"""Write a comprehensive report using the research and analysis:
1. Create executive summary
2. Detail market overview
3. Describe competitive landscape
4. Explain market trends
5. Provide regional analysis
6. Make future projections
7. Add strategic recommendations
8. Answer these questions: {', '.join(questions)}
Format as a professional report with clear sections.""",
agent=writer,
expected_output="Final market research report"
)
]
return Crew(
agents=[researcher, analyst, writer],
tasks=tasks,
process=Process.sequential,
verbose=True
) |