import json
comparison_data = {
"entity_a": {
"name": "NVIDIA",
"scale": a["scale"],
"direction": a["direction"],
"notability": a["notability"],
"notability_reasoning": a.get("notability_reasoning", ""),
"signal_count": a["signal_count"],
"share_of_voice": a["trend"]["share_of_voice"],
"slope": a["trend"]["theil_sen_slope"],
"current_week": a["trend"]["current_week"],
"value_chain_focus": dict(sorted(a_vc.items(), key=lambda x: -x[1])[:3]),
"market_force_focus": dict(sorted(a_mf.items(), key=lambda x: -x[1])[:3]),
"top_co_occurrences": [
r["name"] for r in a.get("related_entities", [])[:5]
],
},
"entity_b": {
"name": "Google",
"scale": b["scale"],
"direction": b["direction"],
"notability": b["notability"],
"notability_reasoning": b.get("notability_reasoning", ""),
"signal_count": b["signal_count"],
"share_of_voice": b["trend"]["share_of_voice"],
"slope": b["trend"]["theil_sen_slope"],
"current_week": b["trend"]["current_week"],
"value_chain_focus": dict(sorted(b_vc.items(), key=lambda x: -x[1])[:3]),
"market_force_focus": dict(sorted(b_mf.items(), key=lambda x: -x[1])[:3]),
"top_co_occurrences": [
r["name"] for r in b.get("related_entities", [])[:5]
],
},
"co_occurrence_count": (
a_related[b["entity_id"]]["co_occurrence_count"]
if b["entity_id"] in a_related else 0
),
}
comparison_json = json.dumps(comparison_data, indent=2)
SYSTEM_PROMPT = """You are a senior competitive intelligence analyst producing a
structured comparison brief. You will receive entity profile data for two companies
from Gildea's AI market intelligence platform, including trend analytics, theme
distributions, and co-occurrence data.
Rules:
- This is for a decision-maker choosing between, competing against, or evaluating
these two entities. Write accordingly.
- Start with a one-sentence positioning statement for each entity.
- Compare on 4 dimensions: Momentum (direction/slope), Scale (absolute size),
Strategic Focus (theme distributions), and Market Context (co-occurrences).
- For each dimension, declare a WINNER or call it a TIE with a one-sentence reason.
- Theme distributions reveal strategy: if Entity A is 80% Infrastructure and Entity B
is 60% Application Layer, that's a real strategic insight, not just a number.
- Co-occurrence data reveals relationships: shared co-occurrences suggest they operate
in the same competitive context. Different co-occurrences suggest different arenas.
- End with a "Bottom Line" — the single most important thing to know about how these
two entities compare right now.
- Keep it under 400 words.
Output format (markdown):
## Competitive Comparison: [Entity A] vs. [Entity B]
### Positioning
- **[Entity A]:** <one-sentence characterization of their current market position>
- **[Entity B]:** <one-sentence characterization of their current market position>
### Head-to-Head
| Dimension | [Entity A] | [Entity B] | Edge |
|-----------|-----------|-----------|------|
| Momentum | <direction, slope> | <direction, slope> | <winner> |
| Scale | <SoV, signal count> | <SoV, signal count> | <winner> |
| Focus | <top themes> | <top themes> | <insight> |
| Context | <top co-occurrences> | <top co-occurrences> | <insight> |
### Strategic Focus Comparison
<2-3 sentences interpreting what the theme distribution differences reveal about
each entity's strategy and competitive positioning>
### Market Context
<2-3 sentences on co-occurrence patterns: who each entity is discussed alongside,
what that reveals, and whether they're competing in the same arena>
### Bottom Line
<1-2 sentences: the single most important takeaway for the decision at hand>
"""
USER_PROMPT = f"""Produce a competitive comparison brief from this entity data:
{comparison_json}
"""
# Pass to your LLM, or print for manual use
print("=== SYSTEM PROMPT ===")
print(SYSTEM_PROMPT)
print("=== USER PROMPT ===")
print(USER_PROMPT)