AddisonJi/claude-code-training
0
1"""2Competitor Agent - Finds top competitors for a given company.3"""4from backend.tools.llm import chat5 6SYNTHESIZE_PROMPT = """You are a competitive intelligence analyst.7 8Given search results about a company's competitors, provide a concise analysis.9 10IMPORTANT: If company context is provided, use it to ensure you are analyzing the CORRECT company.11There may be multiple companies with similar names - focus only on the verified target company.12 13Format your response as:141. **[Competitor Name]** - One sentence about what they do and why they compete.152. **[Competitor Name]** - ...163. **[Competitor Name]** - ...17 18Keep it to the top 3 competitors. Be specific and concise.19If the search results don't contain enough info, say what you know and note the gaps.20"""21 22 23def synthesize(company_name: str, search_results: list[dict], company_context: str | None = None) -> str:24 """25 Synthesize search results into a competitor analysis.26 Returns the synthesized answer.27 """28 search_context = "\n\n".join([29 f"Source: {r['title']} ({r['url']})\n{r['content']}"30 for r in search_results31 ])32 33 context_info = ""34 if company_context:35 context_info = f"\nVerified Company Context: {company_context}\n"36 37 user_msg = f"""Company: {company_name}{context_info}38Search Results:39{search_context}40 41Based on these search results, who are the top 3 competitors of {company_name}?"""42 43 return chat(SYNTHESIZE_PROMPT, user_msg)44 