Update app.py
Browse files
app.py
CHANGED
|
@@ -29,59 +29,59 @@ def generate_cypher(user_query, query_intent, include_cobranded):
|
|
| 29 |
print("inside cypher query gen")
|
| 30 |
|
| 31 |
context_note = f"""
|
| 32 |
-
Contextual Flags:
|
| 33 |
-
- FD Card intent: {query_intent}
|
| 34 |
-
- Include co-branded cards: {include_cobranded}
|
| 35 |
-
"""
|
| 36 |
|
| 37 |
cypher_prompt = f"""
|
| 38 |
-
You are an expert Neo4j Cypher query generator.
|
| 39 |
-
|
| 40 |
-
Given a user’s question, graph schema, and **contextual flags**, generate the correct Cypher query.
|
| 41 |
-
|
| 42 |
-
ONLY output the Cypher query. Do NOT explain anything.
|
| 43 |
-
|
| 44 |
-
---
|
| 45 |
-
|
| 46 |
-
Graph Schema:
|
| 47 |
-
- Nodes:
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
- Relationships:
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
Valid values:
|
| 54 |
-
- card_type: 'FD Card' or 'Regular'
|
| 55 |
-
- premium: true (no concept of false — just include it if applicable)
|
| 56 |
-
- co_branded: true (no concept of false — just include it if applicable)
|
| 57 |
-
|
| 58 |
-
MANDATORY Condition Rules:
|
| 59 |
-
- If FD Card intent is true → include: `c.card_type = 'FD Card'`
|
| 60 |
-
- Else → include: `c.card_type = 'Regular'`
|
| 61 |
-
- If the query uses words like "premium", "elite", "luxury", "exclusive", "infinia", "black", etc. → include: `AND c.premium = true`
|
| 62 |
-
- If include co-branded is false → include: `AND (c.co_branded IS NULL OR c.co_branded = false)`
|
| 63 |
-
- These conditions are **MANDATORY**. If they apply, include them in the `WHERE` clause. Do not skip them.
|
| 64 |
-
|
| 65 |
-
---
|
| 66 |
-
|
| 67 |
-
Available features:
|
| 68 |
-
"Dining Benefits", "Railway Benefits", "Railway Lounge", "Airport Lounge Access", "Travel Benefits",
|
| 69 |
-
"Fuel Surcharge Waiver", "Fuel Benefits", "General Cashback", "General Reward Points", "Movie Benefits",
|
| 70 |
-
"Daily Spends (Grocery)", "Utility", "Insurance & Health Benefits", "Forex Markup Fee", "Hotel Benefits",
|
| 71 |
-
"Welcome Bonus", "Air Miles", "No Forex Markup Fee", "Flight Discounts"
|
| 72 |
-
|
| 73 |
-
Feature Inclusion Rules:
|
| 74 |
-
- Only include relevant features based on user query.
|
| 75 |
-
- Don’t add “General Cashback” or “General Reward Points” unless explicitly mentioned.
|
| 76 |
-
- If fuel is mentioned, include both `Fuel Benefits` and `Fuel Surcharge Waiver`.
|
| 77 |
-
|
| 78 |
-
---
|
| 79 |
-
|
| 80 |
-
{context_note}
|
| 81 |
-
|
| 82 |
-
User Query: {user_query}
|
| 83 |
-
Cypher:
|
| 84 |
-
"""
|
| 85 |
|
| 86 |
response = model3.generate_content(cypher_prompt.strip())
|
| 87 |
cypher_code = response.text.strip()
|
|
|
|
| 29 |
print("inside cypher query gen")
|
| 30 |
|
| 31 |
context_note = f"""
|
| 32 |
+
Contextual Flags:
|
| 33 |
+
- FD Card intent: {query_intent}
|
| 34 |
+
- Include co-branded cards: {include_cobranded}
|
| 35 |
+
"""
|
| 36 |
|
| 37 |
cypher_prompt = f"""
|
| 38 |
+
You are an expert Neo4j Cypher query generator.
|
| 39 |
+
|
| 40 |
+
Given a user’s question, graph schema, and **contextual flags**, generate the correct Cypher query. The query should retrurn only the cards c.
|
| 41 |
+
|
| 42 |
+
ONLY output the Cypher query. Do NOT explain anything.
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
Graph Schema:
|
| 47 |
+
- Nodes:
|
| 48 |
+
- (Card): Properties = name, bank_name, card_type, premium, co_branded
|
| 49 |
+
- (Feature): Properties = name
|
| 50 |
+
- Relationships:
|
| 51 |
+
- (Card)-[:HAS_FEATURE]->(Feature)
|
| 52 |
+
|
| 53 |
+
Valid values:
|
| 54 |
+
- card_type: 'FD Card' or 'Regular'
|
| 55 |
+
- premium: true (no concept of false — just include it if applicable)
|
| 56 |
+
- co_branded: true (no concept of false — just include it if applicable)
|
| 57 |
+
|
| 58 |
+
MANDATORY Condition Rules:
|
| 59 |
+
- If FD Card intent is true → include: `c.card_type = 'FD Card'`
|
| 60 |
+
- Else → include: `c.card_type = 'Regular'`
|
| 61 |
+
- If the query uses words like "premium", "elite", "luxury", "exclusive", "infinia", "black", etc. → include: `AND c.premium = true`
|
| 62 |
+
- If include co-branded is false → include: `AND (c.co_branded IS NULL OR c.co_branded = false)`
|
| 63 |
+
- These conditions are **MANDATORY**. If they apply, include them in the `WHERE` clause. Do not skip them.
|
| 64 |
+
|
| 65 |
+
---
|
| 66 |
+
|
| 67 |
+
Available features:
|
| 68 |
+
"Dining Benefits", "Railway Benefits", "Railway Lounge", "Airport Lounge Access", "Travel Benefits",
|
| 69 |
+
"Fuel Surcharge Waiver", "Fuel Benefits", "General Cashback", "General Reward Points", "Movie Benefits",
|
| 70 |
+
"Daily Spends (Grocery)", "Utility", "Insurance & Health Benefits", "Forex Markup Fee", "Hotel Benefits",
|
| 71 |
+
"Welcome Bonus", "Air Miles", "No Forex Markup Fee", "Flight Discounts"
|
| 72 |
+
|
| 73 |
+
Feature Inclusion Rules:
|
| 74 |
+
- Only include relevant features based on user query.
|
| 75 |
+
- Don’t add “General Cashback” or “General Reward Points” unless explicitly mentioned.
|
| 76 |
+
- If fuel is mentioned, include both `Fuel Benefits` and `Fuel Surcharge Waiver`.
|
| 77 |
+
|
| 78 |
+
---
|
| 79 |
+
|
| 80 |
+
{context_note}
|
| 81 |
+
|
| 82 |
+
User Query: {user_query}
|
| 83 |
+
Cypher:
|
| 84 |
+
"""
|
| 85 |
|
| 86 |
response = model3.generate_content(cypher_prompt.strip())
|
| 87 |
cypher_code = response.text.strip()
|