| | from crewai import Agent, Crew, Process, Task |
| | from crewai_tools import SerperDevTool, ScrapeWebsiteTool |
| | from langchain_openai import ChatOpenAI |
| | import streamlit as st |
| |
|
| | |
| | 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 |
| | ) |