Spaces:
Sleeping
Sleeping
Update agents.py
Browse files
agents.py
CHANGED
|
@@ -6,7 +6,7 @@ from langchain.tools import Tool
|
|
| 6 |
# agents.py
|
| 7 |
class MarketResearchTools:
|
| 8 |
"""Advanced research tools using Serper capabilities"""
|
| 9 |
-
|
| 10 |
def __init__(self):
|
| 11 |
self.serper = SerperDevTool()
|
| 12 |
self.scraper = ScrapeWebsiteTool()
|
|
@@ -42,7 +42,7 @@ class MarketResearchTools:
|
|
| 42 |
|
| 43 |
return self.serper.run(base_query)
|
| 44 |
|
| 45 |
-
|
| 46 |
"""Create an advanced research crew with specialized tools"""
|
| 47 |
try:
|
| 48 |
tools = MarketResearchTools()
|
|
@@ -52,10 +52,10 @@ class MarketResearchTools:
|
|
| 52 |
role='Senior Market Research Analyst',
|
| 53 |
goal=f'Conduct exhaustive market research about {topic} with detailed data and industry insights',
|
| 54 |
backstory="""You are a veteran market research analyst with 20+ years of experience.
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
tools=[
|
| 60 |
tools.market_search, # For general market research
|
| 61 |
tools.scraper, # For website scraping
|
|
@@ -68,9 +68,9 @@ class MarketResearchTools:
|
|
| 68 |
role='Industry Expert & Strategy Analyst',
|
| 69 |
goal='Transform research into strategic insights and actionable recommendations',
|
| 70 |
backstory="""You are an industry expert with deep domain knowledge and strategic consulting
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
tools=[tools.market_search], # Only needs market search
|
| 75 |
verbose=True
|
| 76 |
)
|
|
@@ -80,97 +80,97 @@ class MarketResearchTools:
|
|
| 80 |
role='Executive Report Writer',
|
| 81 |
goal='Create compelling, comprehensive market analysis reports',
|
| 82 |
backstory="""You are an experienced business writer who specializes in creating
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
verbose=True
|
| 87 |
)
|
| 88 |
|
| 89 |
# Create enhanced tasks
|
| 90 |
research_task = Task(
|
| 91 |
description=f"""
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
agent=researcher,
|
| 136 |
expected_output="Comprehensive research data with verified sources and confidence levels"
|
| 137 |
)
|
| 138 |
|
| 139 |
analysis_task = Task(
|
| 140 |
description="""
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
agent=analyst,
|
| 175 |
expected_output="Strategic analysis with actionable insights",
|
| 176 |
context=[research_task]
|
|
@@ -178,62 +178,62 @@ class MarketResearchTools:
|
|
| 178 |
|
| 179 |
report_task = Task(
|
| 180 |
description="""
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
|
|
|
| 226 |
}
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
""",
|
| 237 |
agent=writer,
|
| 238 |
expected_output="Professional report with executive summary and detailed analysis",
|
| 239 |
context=[research_task, analysis_task]
|
|
|
|
| 6 |
# agents.py
|
| 7 |
class MarketResearchTools:
|
| 8 |
"""Advanced research tools using Serper capabilities"""
|
| 9 |
+
|
| 10 |
def __init__(self):
|
| 11 |
self.serper = SerperDevTool()
|
| 12 |
self.scraper = ScrapeWebsiteTool()
|
|
|
|
| 42 |
|
| 43 |
return self.serper.run(base_query)
|
| 44 |
|
| 45 |
+
def create_research_crew(topic: str):
|
| 46 |
"""Create an advanced research crew with specialized tools"""
|
| 47 |
try:
|
| 48 |
tools = MarketResearchTools()
|
|
|
|
| 52 |
role='Senior Market Research Analyst',
|
| 53 |
goal=f'Conduct exhaustive market research about {topic} with detailed data and industry insights',
|
| 54 |
backstory="""You are a veteran market research analyst with 20+ years of experience.
|
| 55 |
+
You excel at uncovering hard-to-find data points, analyzing industry dynamics,
|
| 56 |
+
and identifying emerging trends. You have a strong network of industry contacts
|
| 57 |
+
and access to premium research databases. You always validate data through
|
| 58 |
+
multiple sources and provide confidence levels for your findings.""",
|
| 59 |
tools=[
|
| 60 |
tools.market_search, # For general market research
|
| 61 |
tools.scraper, # For website scraping
|
|
|
|
| 68 |
role='Industry Expert & Strategy Analyst',
|
| 69 |
goal='Transform research into strategic insights and actionable recommendations',
|
| 70 |
backstory="""You are an industry expert with deep domain knowledge and strategic consulting
|
| 71 |
+
experience. You specialize in connecting market data to business implications,
|
| 72 |
+
forecasting industry changes, and developing strategic recommendations.
|
| 73 |
+
Your analysis is always backed by concrete examples and case studies.""",
|
| 74 |
tools=[tools.market_search], # Only needs market search
|
| 75 |
verbose=True
|
| 76 |
)
|
|
|
|
| 80 |
role='Executive Report Writer',
|
| 81 |
goal='Create compelling, comprehensive market analysis reports',
|
| 82 |
backstory="""You are an experienced business writer who specializes in creating
|
| 83 |
+
executive-level market research reports. You excel at distilling complex
|
| 84 |
+
information into clear narratives while maintaining analytical rigor.
|
| 85 |
+
You always include relevant examples, case studies, and data visualizations.""",
|
| 86 |
verbose=True
|
| 87 |
)
|
| 88 |
|
| 89 |
# Create enhanced tasks
|
| 90 |
research_task = Task(
|
| 91 |
description=f"""
|
| 92 |
+
Conduct comprehensive market research on {topic} with the following focus areas:
|
| 93 |
+
|
| 94 |
+
1. Market Overview:
|
| 95 |
+
- Current market size with specific values
|
| 96 |
+
- Historical growth patterns (5-year minimum)
|
| 97 |
+
- Future projections with CAGR
|
| 98 |
+
- Market segmentation analysis
|
| 99 |
+
- Regional market distribution
|
| 100 |
+
- Value chain analysis
|
| 101 |
+
- Pricing trends and dynamics
|
| 102 |
+
|
| 103 |
+
2. Competitive Landscape:
|
| 104 |
+
- Detailed analysis of top 5-7 players
|
| 105 |
+
- Market share breakdown
|
| 106 |
+
- Competitive strategies
|
| 107 |
+
- Recent developments and initiatives
|
| 108 |
+
- SWOT analysis of major players
|
| 109 |
+
- Barriers to entry analysis
|
| 110 |
+
- Industry concentration metrics
|
| 111 |
+
|
| 112 |
+
3. Technology & Innovation:
|
| 113 |
+
- Current technology trends
|
| 114 |
+
- Innovation patterns
|
| 115 |
+
- Patent analysis
|
| 116 |
+
- R&D investments
|
| 117 |
+
- Emerging technologies
|
| 118 |
+
- Digital transformation trends
|
| 119 |
+
|
| 120 |
+
4. Regulatory & Environmental Factors:
|
| 121 |
+
- Current regulations
|
| 122 |
+
- Upcoming policy changes
|
| 123 |
+
- Environmental considerations
|
| 124 |
+
- Compliance requirements
|
| 125 |
+
- Industry standards
|
| 126 |
+
- Certification needs
|
| 127 |
+
|
| 128 |
+
Requirements:
|
| 129 |
+
- Use multiple sources for each data point
|
| 130 |
+
- Focus on recent data (last 12 months)
|
| 131 |
+
- Include source citations
|
| 132 |
+
- Note confidence levels for projections
|
| 133 |
+
- Identify any data gaps or inconsistencies
|
| 134 |
+
""",
|
| 135 |
agent=researcher,
|
| 136 |
expected_output="Comprehensive research data with verified sources and confidence levels"
|
| 137 |
)
|
| 138 |
|
| 139 |
analysis_task = Task(
|
| 140 |
description="""
|
| 141 |
+
Analyze the research findings and create strategic insights:
|
| 142 |
+
|
| 143 |
+
1. Strategic Analysis:
|
| 144 |
+
- Porter's Five Forces analysis
|
| 145 |
+
- PESTLE analysis
|
| 146 |
+
- Value chain opportunities
|
| 147 |
+
- Growth vectors
|
| 148 |
+
- Market maturity assessment
|
| 149 |
+
- Investment potential
|
| 150 |
+
|
| 151 |
+
2. Trend Analysis:
|
| 152 |
+
- Major market trends
|
| 153 |
+
- Technology impact assessment
|
| 154 |
+
- Consumer behavior shifts
|
| 155 |
+
- Emerging business models
|
| 156 |
+
- Future scenarios
|
| 157 |
+
- Risk assessment
|
| 158 |
+
|
| 159 |
+
3. Strategic Implications:
|
| 160 |
+
- Market entry strategies
|
| 161 |
+
- Growth opportunities
|
| 162 |
+
- Potential threats
|
| 163 |
+
- Success factors
|
| 164 |
+
- Risk mitigation strategies
|
| 165 |
+
- Partnership opportunities
|
| 166 |
+
|
| 167 |
+
Requirements:
|
| 168 |
+
- Provide concrete examples
|
| 169 |
+
- Include case studies
|
| 170 |
+
- Support all conclusions with data
|
| 171 |
+
- Identify key success factors
|
| 172 |
+
- Assess market attractiveness
|
| 173 |
+
""",
|
| 174 |
agent=analyst,
|
| 175 |
expected_output="Strategic analysis with actionable insights",
|
| 176 |
context=[research_task]
|
|
|
|
| 178 |
|
| 179 |
report_task = Task(
|
| 180 |
description="""
|
| 181 |
+
Create a comprehensive market research report:
|
| 182 |
+
|
| 183 |
+
1. Executive Summary (2-3 pages):
|
| 184 |
+
- Key findings
|
| 185 |
+
- Market highlights
|
| 186 |
+
- Strategic implications
|
| 187 |
+
- Recommendations
|
| 188 |
+
- Investment thesis
|
| 189 |
+
|
| 190 |
+
2. Comprehensive Analysis (15-20 pages):
|
| 191 |
+
- Detailed market analysis
|
| 192 |
+
- Competitive landscape
|
| 193 |
+
- Strategic insights
|
| 194 |
+
- Future outlook
|
| 195 |
+
- Risk analysis
|
| 196 |
+
|
| 197 |
+
3. Supporting Materials:
|
| 198 |
+
- Case studies
|
| 199 |
+
- Company profiles
|
| 200 |
+
- Data tables
|
| 201 |
+
- Source citations
|
| 202 |
+
- Methodology notes
|
| 203 |
+
|
| 204 |
+
Format as JSON:
|
| 205 |
+
{
|
| 206 |
+
"exec_summary": {
|
| 207 |
+
"summary": "comprehensive executive overview",
|
| 208 |
+
"market_highlights": "key market metrics and findings",
|
| 209 |
+
"strategic_implications": "main strategic insights",
|
| 210 |
+
"recommendations": "key recommendations"
|
| 211 |
+
},
|
| 212 |
+
"market_analysis": {
|
| 213 |
+
"overview": "detailed market overview section",
|
| 214 |
+
"dynamics": "comprehensive industry dynamics",
|
| 215 |
+
"competitive_landscape": "detailed competitive analysis",
|
| 216 |
+
"strategic_analysis": "in-depth strategic insights"
|
| 217 |
+
},
|
| 218 |
+
"future_outlook": "detailed future projections and implications",
|
| 219 |
+
"appendices": "supporting data and sources",
|
| 220 |
+
"sources": ["source1", "source2", "..."],
|
| 221 |
+
"metrics": {
|
| 222 |
+
"market_size": "current and projected size",
|
| 223 |
+
"growth_rate": "historical and projected growth",
|
| 224 |
+
"market_shares": "key player market shares",
|
| 225 |
+
"key_metrics": "other important metrics"
|
| 226 |
+
}
|
| 227 |
}
|
| 228 |
+
|
| 229 |
+
Requirements:
|
| 230 |
+
- Clear, professional writing
|
| 231 |
+
- Logical flow of information
|
| 232 |
+
- Evidence-based conclusions
|
| 233 |
+
- Actionable recommendations
|
| 234 |
+
- 5-10 credible sources
|
| 235 |
+
- Recent data points
|
| 236 |
+
""",
|
|
|
|
| 237 |
agent=writer,
|
| 238 |
expected_output="Professional report with executive summary and detailed analysis",
|
| 239 |
context=[research_task, analysis_task]
|