diff --git a/market_intel_orchestrator.py b/market_intel_orchestrator.py index c771ed06..c8fe985c 100644 --- a/market_intel_orchestrator.py +++ b/market_intel_orchestrator.py @@ -175,26 +175,28 @@ def generate_search_strategy(reference_url, context_content): prompt = f""" You are a B2B Market Intelligence Architect. - --- STRATEGIC CONTEXT --- + --- ROLE DEFINITION --- + You are working for the company described in the "STRATEGIC CONTEXT" below (The "Hunter"). + Your goal is to find new potential customers who look exactly like the "REFERENCE CLIENT" described below (The "Seed" / "Prey"). + + --- STRATEGIC CONTEXT (YOUR COMPANY / THE OFFER) --- {context_content} - --- EXTRACTED TARGET INDUSTRIES --- - {', '.join(target_industries)} - - --- REFERENCE CLIENT HOMEPAGE --- - {homepage_text[:10000] if homepage_text else "No Homepage Text"} + --- REFERENCE CLIENT HOMEPAGE (THE IDEAL CUSTOMER TO CLONE) --- + URL: {reference_url} + CONTENT: {homepage_text[:10000] if homepage_text else "No Homepage Text"} --- TASK --- - Based on the context and the reference client's homepage, develop a search strategy to find similar companies (competitors/lookalikes) and audit them to find sales triggers. + Develop a search strategy to find **Lookalikes of the Reference Client** who would be interested in **Your Company's Offer**. - 1. **summaryOfOffer**: A 1-sentence summary of what the reference client sells. - 2. **idealCustomerProfile**: A concise definition of the Ideal Customer Profile (ICP) based on the reference client. + 1. **summaryOfOffer**: A 1-sentence summary of what the **REFERENCE CLIENT** does (NOT what your company does). We need this to search for similar companies. + 2. **idealCustomerProfile**: A concise definition of the Ideal Customer Profile (ICP) based on the Reference Client's characteristics. 3. **searchStrategyICP**: A detailed description of the Ideal Customer Profile (ICP) based on the analysis. - 4. **digitalSignals**: Identification and description of relevant digital signals that indicate purchase interest or engagement. + 4. **digitalSignals**: Identification and description of relevant digital signals that indicate purchase interest or engagement for YOUR offer. 5. **targetPages**: A list of the most important target pages on the company website relevant for marketing and sales activities. - 6. **signals**: Identify exactly 4 specific digital signals. - - **CRITICAL**: One signal MUST be "Technographic / Incumbent Search". It must look for existing competitor software or legacy systems that our offer replaces or complements (e.g., "Uses SAP Ariba", "Has Supplier Portal", "Uses Salesforce"). - - The other 3 signals should focus on business pains or strategic fit (e.g., "Sustainability Report", "Supply Chain Complexity"). + 6. **signals**: Identify exactly 4 specific digital signals to check on potential lookalikes. + - **CRITICAL**: One signal MUST be "Technographic / Incumbent Search". It must look for existing competitor software or legacy systems that **YOUR COMPANY'S OFFER** replaces or complements. + - The other 3 signals should focus on business pains or strategic fit. --- SIGNAL DEFINITION --- For EACH signal, you MUST provide: @@ -210,30 +212,17 @@ def generate_search_strategy(reference_url, context_content): --- OUTPUT FORMAT --- Return ONLY a valid JSON object. {{ - "summaryOfOffer": "...", + "summaryOfOffer": "The Reference Client provides...", "idealCustomerProfile": "...", "searchStrategyICP": "...", "digitalSignals": "...", "targetPages": "...", - "signals": [ - {{ - "id": "sig_1", - "name": "...", - "description": "...", - "targetPageKeywords": ["..."], - "proofStrategy": {{ - "likelySource": "...", - "searchQueryTemplate": "..." - }} - }}, - ... - ] + "signals": [ ... ] }} """ payload = {"contents": [{"parts": [{"text": prompt}]}]} logger.info("Sende Anfrage an Gemini API...") - # logger.debug(f"Rohe Gemini API-Anfrage (JSON): {json.dumps(payload, indent=2)}") try: response = requests.post(GEMINI_API_URL, json=payload, headers={'Content-Type': 'application/json'}) response.raise_for_status() @@ -241,6 +230,10 @@ def generate_search_strategy(reference_url, context_content): logger.info(f"Gemini API-Antwort erhalten (Status: {response.status_code}).") text = res_json['candidates'][0]['content']['parts'][0]['text'] + + # DEBUG LOGGING FOR RAW JSON + logger.error(f"RAW GEMINI JSON RESPONSE: {text}") + result = _extract_json_from_text(text) if not result: @@ -270,12 +263,15 @@ def identify_competitors(reference_url, target_market, industries, summary_of_of You are a B2B Market Analyst. Find 3-5 direct competitors or highly similar companies (lookalikes) for the company at `{reference_url}`. --- CONTEXT --- - - Offer: {summary_of_offer} + - Reference Client Business (What they do): {summary_of_offer} - Target Market: {target_market} - Relevant Industries: {', '.join(industries)} --- TASK --- - Identify competitors and categorize them into three groups: + Identify companies that are **similar to the Reference Client** (i.e., Lookalikes). + We are looking for other companies that do the same thing as `{reference_url}`. + + Categorize them into three groups: 1. 'localCompetitors': Competitors in the same immediate region/city. 2. 'nationalCompetitors': Competitors operating across the same country. 3. 'internationalCompetitors': Global players.