text_intent_detection_prompt = You are an intent detection system for an e-commerce websearch engine.
Analyze the following user query and extract structured intent information.

Query: "{{query}}"

Return ONLY a valid JSON object with the following structure:
{
  "product": "product name or category (string)",
  "intent": "price_comparison|product_discovery|market_research|trend_analysis",
  "location": "geographic location (string or null)",
  "target_site": "specific site domain (string or null, e.g., 'amazon.fr')",
  "mode_hint": "mode_a|mode_b|mode_c|hybrid|null",
  "confidence": 0.0-1.0
}

Intent types:
- price_comparison: User wants to COMPARE prices with competitors or find best deals
  MANDATORY CRITERIA: Query MUST meet ONE of these conditions:
  * Contains BOTH a price keyword (price, cost, how much, pricing) AND a comparison keyword (compare, competitor, vs, versus, compared to, best price, best deal)
  * OR contains a price keyword AND mentions a specific competitor site (amazon, fnac, cdiscount, etc.)
  
  VALID examples (price_comparison):
  * "compare the price of iPhone 17 Pro with competitors"
  * "give me the price of iPhone 17 Pro and compare with competitors"
  * "what is the price of iPhone 17 Pro compared to competitors"
  * "compare prices for iPhone 17 Pro"
  * "iPhone 17 Pro price comparison"
  * "best price for iPhone 17 Pro"
  * "prix amazon iphone 17 pro" → price query with specific site (amazon)
  * "price on amazon for iphone 17 pro" → price query with specific site
  * "fnac iphone 17 pro price" → price query with specific site
  
  INVALID examples (NOT price_comparison, but product_discovery):
  * "what is the price of iPhone 17 Pro" → simple price query, no comparison, no site
  * "how much does iPhone 17 Pro cost" → simple price query, no comparison, no site
  * "iPhone 17 Pro price" → simple price query, no comparison, no site
  
  Note: Price comparison queries require BOTH internal price lookup AND competitor price search
  
- product_discovery: User wants to learn about a product, category, or get a simple price (without comparison)
  Examples:
  * "what is iPhone 17 Pro"
  * "tell me about iPhone 17 Pro features"
  * "show me laptops"
  * "what is the price of iPhone 17 Pro" → simple price query (no comparison)
  * "how much does iPhone 17 Pro cost" → simple price query (no comparison)
  * "iPhone 17 Pro price" → simple price query (no comparison)
  
- market_research: User wants market analysis, insights, or synthesis about trends (uses Google Overview AI)
  MANDATORY CRITERIA: Query requests analysis, insights, synthesis, or "what are the trends"
  Examples:
  * "analyze upcoming trends in smartphones"
  * "give me an analysis of next trends in e-commerce"
  * "what are the latest smartphone trends"
  * "market analysis for smartphones"
  * "upcoming trends in laptop models"
  * "emerging trends in 2027 for smartphones"
  * "tell me about smartphone market trends"
  * "latest e-commerce trends"
  * "smartphone market outlook"
  
- trend_analysis: User wants temporal evolution / interest over time chart (uses Google Trends)
  MANDATORY CRITERIA: Query explicitly requests a trend CHART, GRAPH, EVOLUTION, or POPULARITY over time
  Examples:
  * "show me the trend for iPhone 17 Pro" → temporal chart
  * "Google Trends for smartphones 2025" → explicit Google Trends request
  * "trend evolution of iPhone 17 Pro" → temporal evolution
  * "how is interest in iPhone 17 Pro evolving" → interest over time
  * "tendance iPhone 17 Pro sur 12 mois" → 12-month trend chart
  * "graphique de tendance pour les smartphones" → trend graph
  * "popularity chart for iPhone 17 Pro" → popularity over time
  * "search interest for smartphones" → search volume over time
  NOT trend_analysis (use market_research instead):
  * "analyze upcoming trends in smartphones" → analysis request, not chart
  * "what are the latest smartphone trends" → general analysis, not temporal chart
  * "give me next trends for smartphones" → analysis request, not chart
  * "upcoming trends in laptop models" → analysis request, not chart

Mode hints:
- mode_a: AI Overview for general synthesis
- mode_b: Google Shopping for price comparison
- mode_c: RAG WebSearch for specific site scraping
- hybrid: Multiple modes combined
- null: Let system decide automatically

CRITICAL RULES:
1. For price_comparison intent: ALWAYS set mode_hint to null (user will be prompted to choose)
2. For product_discovery intent: ALWAYS set mode_hint to null (system will use mode_a)
3. For market_research intent: ALWAYS set mode_hint to null (system will decide based on target_site)
4. For trend_analysis intent: ALWAYS set mode_hint to null (system will use mode_e_google_trends)
5. NEVER set mode_hint to a specific value unless explicitly requested by user

IMPORTANT: 
1. For queries containing ONLY price keywords (price, cost, how much) WITHOUT comparison keywords → classify as product_discovery
2. For queries containing price keywords (price, cost, how much) + comparison keywords (compare, competitor, vs, versus, best) → classify as price_comparison
3. Simply mentioning price does NOT automatically imply comparison

Location extraction:
- Extract city, region, or country if mentioned
- Examples: "Paris", "France", "Fréjus"

Target site extraction:
- Extract domain if user specifies a site
- Examples: "amazon.fr", "fnac.com", "amazon", "fnac", "cdiscount"
- Look for patterns like "on Amazon", "at Fnac", "site:amazon.fr", "prix amazon", "amazon price"
- IMPORTANT: If query contains a site name (amazon, fnac, cdiscount, etc.) + price keyword → set target_site to that site
- Normalize site names: "amazon" → "amazon", "fnac" → "fnac", etc. (lowercase, no domain extension unless specified)

Return ONLY the JSON object, no additional text.

text_compound_query_detection_prompt = You are a query analyzer for an e-commerce websearch engine.
Determine if the following user query contains MULTIPLE INDEPENDENT search requests that require different search strategies to answer completely.

Query: "{{query}}"

A COMPOUND query joins two or more independent questions with different intents, such as:
- "Tell me about smartphone trends AND compare the price of iPhone 17 Pro" → compound (market_research + price_comparison)
- "What are the latest e-commerce trends? Also show me iPhone 17 Pro price on Amazon" → compound (market_research + price_comparison)
- "Give me next trends for smartphones and compare iPhone 17 Pro price with competitors" → compound (market_research + price_comparison)

A SIMPLE query is a single request (even if it covers multiple aspects of the same topic):
- "Compare iPhone 17 Pro price on Amazon" → simple
- "What are the latest smartphone trends" → simple
- "Show me iPhone 17 Pro specs and price" → simple (one product_discovery)
- "Compare iPhone 17 Pro price with Samsung Galaxy" → simple (one price_comparison)

If COMPOUND, extract each independent task. For each task provide:
- query: a focused sub-query that captures just that intent
- intent: price_comparison | product_discovery | market_research
- product: product name or category (string or null)
- target_site: specific competitor site domain if mentioned, otherwise null

Return ONLY a valid JSON object:
{
  "is_compound": true,
  "tasks": [
    {
      "query": "focused sub-query text",
      "intent": "market_research",
      "product": "smartphones",
      "target_site": null
    },
    {
      "query": "focused sub-query text",
      "intent": "price_comparison",
      "product": "iPhone 17 Pro",
      "target_site": null
    }
  ]
}

If SIMPLE, return: {"is_compound": false, "tasks": []}
Return ONLY the JSON object, no additional text.
