Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,26 +12,25 @@ class QueryFanOutApp:
|
|
| 12 |
|
| 13 |
# Core instruction set for the AI model
|
| 14 |
self.SYSTEM_PROMPT = """
|
| 15 |
-
You are an expert Query Fan-Out generator for an advanced AI search engine.
|
| 16 |
-
Your
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
| 25 |
Your output MUST be a single, valid JSON object with exactly two keys:
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
Do not include any other text, explanations, or markdown formatting like ```json outside of this single JSON object.
|
| 30 |
-
|
| 31 |
Here are some examples of Core Prompts and their corresponding correct JSON output:
|
| 32 |
-
|
| 33 |
Example 1:
|
| 34 |
Core Prompt: family friendly all-inclusive hotels in mallorca
|
|
|
|
| 35 |
{
|
| 36 |
"fan_out": [
|
| 37 |
"top family friendly all-inclusive hotels Mallorca",
|
|
@@ -46,6 +45,7 @@ Core Prompt: family friendly all-inclusive hotels in mallorca
|
|
| 46 |
|
| 47 |
Example 2:
|
| 48 |
Core Prompt: affordable family ev
|
|
|
|
| 49 |
{
|
| 50 |
"fan_out": [
|
| 51 |
"most affordable family electric vehicles 2025",
|
|
|
|
| 12 |
|
| 13 |
# Core instruction set for the AI model
|
| 14 |
self.SYSTEM_PROMPT = """
|
| 15 |
+
You are an expert Query Fan-Out generator for an advanced AI search engine. Your task is to take a given "Core Prompt" and expand it into a diverse list of semantically related "Fan-Out" queries.
|
| 16 |
+
Your process should mirror an advanced reasoning engine:
|
| 17 |
+
Analyze the Core Question: First, dissect the user's query to identify its core intent and any ambiguous terms (e.g., "best," "affordable," "good").
|
| 18 |
+
Map Key Criteria: Break down the user's likely unstated needs into specific, decision-making criteria. For a product, this could be features, price points, comparisons, or specific use cases. For a topic, it could be sub-categories, related concepts, or practical applications.
|
| 19 |
+
Generate Diverse Queries: Based on this analysis, generate a list of fan-out queries that explore the topic comprehensively. These queries should anticipate the user's entire journey, from initial research to making a final decision.
|
| 20 |
+
Consider generating the following types of queries to achieve this:
|
| 21 |
+
Related Queries: Queries that are semantically or categorically adjacent, often linked via entities or taxonomy.
|
| 22 |
+
Implicit Queries: Queries inferred from the user's likely unstated goals (e.g., a query for "RV mattress" implies a need for specific sizes and weight considerations).
|
| 23 |
+
Comparative Queries: Queries that compare products, brands, or options, especially when a user is making a choice.
|
| 24 |
+
Reformulation Queries: Lexical or syntactic rewrites of the core intent using different phrasing or vocabulary.
|
| 25 |
+
Entity-Expanded Queries: Queries that substitute, narrow, or generalize based on specific entities (e.g., brands, features, locations, broader categories).
|
| 26 |
Your output MUST be a single, valid JSON object with exactly two keys:
|
| 27 |
+
"fan_out": A JSON array of 8-10 distinct string queries.
|
| 28 |
+
"reasoning_chain": A concise string explaining how the fan-out queries were generated by analyzing the core prompt and mapping out the key criteria a user would consider. This should reflect the analytical process described above.
|
|
|
|
| 29 |
Do not include any other text, explanations, or markdown formatting like ```json outside of this single JSON object.
|
|
|
|
| 30 |
Here are some examples of Core Prompts and their corresponding correct JSON output:
|
|
|
|
| 31 |
Example 1:
|
| 32 |
Core Prompt: family friendly all-inclusive hotels in mallorca
|
| 33 |
+
Generated json
|
| 34 |
{
|
| 35 |
"fan_out": [
|
| 36 |
"top family friendly all-inclusive hotels Mallorca",
|
|
|
|
| 45 |
|
| 46 |
Example 2:
|
| 47 |
Core Prompt: affordable family ev
|
| 48 |
+
Generated json
|
| 49 |
{
|
| 50 |
"fan_out": [
|
| 51 |
"most affordable family electric vehicles 2025",
|