LogicGoInfotechSpaces commited on
Commit
9ab0023
·
1 Parent(s): 4040861

Update OpenAI prompt to be global/worldwide instead of India-specific for international users

Browse files
Files changed (1) hide show
  1. app/smart_recommendation.py +70 -23
app/smart_recommendation.py CHANGED
@@ -945,32 +945,79 @@ class SmartBudgetRecommender:
945
  )
946
 
947
  prompt = (
948
- "You are an expert Indian personal finance coach. "
949
- "Analyze the user's spending history and provide a smart, personalized budget recommendation.\n\n"
950
- "IMPORTANT: You MUST analyze the spending pattern and provide a recommendation that is DIFFERENT from just keeping the same amount.\n\n"
951
- "Analysis Guidelines:\n"
952
- "1. TRENDING UPWARD: If monthly values show an increasing trend (later months > earlier months), "
953
- " recommend INCREASE by 10-25% to accommodate the growth trend.\n"
954
- " Example: [180000, 190000, 200000] Recommend ~220000-250000 (increase)\n\n"
955
- "2. TRENDING DOWNWARD: If monthly values show a decreasing trend (later months < earlier months), "
956
- " recommend DECREASE by 5-15% to reflect the reduction.\n"
957
- " Example: [220000, 210000, 200000] → Recommend ~180000-190000 (decrease)\n\n"
958
- "3. HIGH VARIATION: If std_dev is high (>15% of average), recommend INCREASE by 15-25% "
959
- " to create a safety buffer for unpredictable spending.\n"
960
- " Example: std_dev = 30000, avg = 200000 → Recommend ~230000-250000 (increase)\n\n"
961
- "4. STABLE & LOW VARIATION: Only if spending is very stable (std_dev < 5% of average) "
962
- " AND no clear trend, then KEEP with a small 5% buffer.\n"
963
- " Example: [200000, 200000, 200000] with std_dev < 10000 Recommend ~210000 (keep with buffer)\n\n"
964
- "5. SINGLE DATA POINT: If only one month of data, recommend INCREASE by 10-15% "
965
- " to account for potential variability.\n\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
966
  "Given the user's spending history:\n"
967
  f"{summary}\n\n"
968
- "CRITICAL: Do NOT always recommend 'keep'. Analyze the pattern and provide increase/decrease/keep based on the actual data trends.\n"
969
- "The recommended_budget MUST reflect your analysis - if there's a trend, the budget should reflect it.\n\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
970
  "Respond strictly as JSON with the following keys:\n"
971
- '{ "recommended_budget": number, "action": "increase|decrease|keep", "reason": "string" }.\n'
972
- "The reason must be specific, explain the trend you observed, and justify why you chose increase/decrease/keep.\n"
973
- "Use rupees for all amounts. Round recommended_budget to nearest 100.\n"
 
 
 
 
 
 
 
 
 
974
  )
975
 
976
  try:
 
945
  )
946
 
947
  prompt = (
948
+ "You are an expert global personal finance coach with deep knowledge of:\n"
949
+ "- Spending patterns across different categories worldwide (Food, Transport, Entertainment, Utilities, etc.)\n"
950
+ "- Economic trends and inflation impacts globally\n"
951
+ "- Seasonal variations in spending (holidays, weather, cultural events)\n"
952
+ "- Best practices for budget management and financial planning\n"
953
+ "- Category-specific insights (e.g., Food & Drinks tend to have inflation, Transport varies with fuel prices)\n"
954
+ "- Regional economic factors and currency considerations\n\n"
955
+ "TASK: Analyze the user's spending history intelligently using your knowledge and provide a smart, personalized budget recommendation.\n\n"
956
+ "INTELLIGENT ANALYSIS APPROACH:\n\n"
957
+ "1. CATEGORY-SPECIFIC KNOWLEDGE:\n"
958
+ " - Food & Drinks: Consider inflation (typically 2-5% annually globally), seasonal spikes, cultural events\n"
959
+ " - Transport/Travel: Fuel price volatility, seasonal travel patterns, regional variations\n"
960
+ " - Entertainment: Weekend/holiday variations, seasonal trends, cultural events\n"
961
+ " - Utilities: Seasonal variations (cooling in summer, heating in winter, regional differences)\n"
962
+ " - Healthcare: Unpredictable but essential, recommend buffer\n"
963
+ " - Use your knowledge about how this category typically behaves globally\n\n"
964
+ "2. TREND ANALYSIS:\n"
965
+ " - TRENDING UPWARD: If spending is increasing, consider if it's:\n"
966
+ " * Inflation-driven (recommend increase to match inflation + buffer)\n"
967
+ " * Lifestyle change (recommend increase with caution and explanation)\n"
968
+ " * One-time spike (recommend keep or slight increase, explain it's temporary)\n"
969
+ " * Seasonal pattern (recommend increase if entering high-spending season)\n"
970
+ " - TRENDING DOWNWARD: If spending is decreasing, consider if it's:\n"
971
+ " * Sustainable reduction (recommend decrease to reflect new pattern)\n"
972
+ " * Temporary dip (recommend keep with buffer for recovery)\n"
973
+ " * Seasonal pattern (recommend decrease if entering low-spending season)\n\n"
974
+ "3. VARIABILITY INTELLIGENCE:\n"
975
+ " - HIGH VARIATION (std_dev > 15%): Indicates unpredictable spending\n"
976
+ " * Recommend INCREASE by 20-30% to create safety buffer\n"
977
+ " * Explain that high variability requires larger buffer for financial security\n"
978
+ " - LOW VARIATION (std_dev < 5%): Indicates stable spending\n"
979
+ " * Can recommend KEEP or small increase (5-10% for inflation buffer)\n"
980
+ " * Still consider category-specific factors and economic trends\n\n"
981
+ "4. ECONOMIC CONTEXT:\n"
982
+ " - Consider global inflation trends (typically 2-5% annually in most countries)\n"
983
+ " - Factor in category-specific inflation (food inflation often higher than general inflation)\n"
984
+ " - Account for seasonal price variations (holidays, weather, supply/demand)\n"
985
+ " - Consider regional economic factors if relevant\n\n"
986
+ "5. BEST PRACTICES:\n"
987
+ " - Always include a small buffer (5-10%) even for stable spending to handle unexpected expenses\n"
988
+ " - For new budgets (single data point), be conservative but realistic (10-15% buffer)\n"
989
+ " - Consider the user's spending history length (more data = more confidence in recommendation)\n"
990
+ " - Apply the 50/30/20 rule principles when appropriate (needs/wants/savings)\n\n"
991
  "Given the user's spending history:\n"
992
  f"{summary}\n\n"
993
+ "YOUR INTELLIGENT RECOMMENDATION:\n"
994
+ "1. Analyze the spending pattern using your knowledge of this category globally\n"
995
+ "2. Consider economic factors, seasonal trends, and best practices\n"
996
+ "3. Provide a SMART recommendation that:\n"
997
+ " - Reflects actual trends in the data\n"
998
+ " - Accounts for category-specific factors\n"
999
+ " - Includes appropriate buffer for variability and inflation\n"
1000
+ " - Is justified by your analysis and knowledge\n\n"
1001
+ "CRITICAL RULES:\n"
1002
+ "- Do NOT always recommend 'keep' - use your intelligence to determine the best action\n"
1003
+ "- If there's an upward trend, recommend INCREASE (don't ignore the trend)\n"
1004
+ "- If there's high variation, recommend INCREASE to create buffer\n"
1005
+ "- If spending is stable AND category is predictable, you can recommend KEEP with small buffer (5-10%)\n"
1006
+ "- The recommended_budget should be SMART: Specific, Measurable, Achievable, Relevant, Time-bound\n"
1007
+ "- Consider inflation: even stable spending should account for 2-5% annual inflation\n\n"
1008
  "Respond strictly as JSON with the following keys:\n"
1009
+ '{ "recommended_budget": number, "action": "increase|decrease|keep", "reason": "string" }.\n\n'
1010
+ "The 'reason' field is CRITICAL - it must:\n"
1011
+ "- Explain the spending pattern you observed\n"
1012
+ "- Reference category-specific knowledge if relevant\n"
1013
+ "- Justify why you chose increase/decrease/keep\n"
1014
+ "- Be specific, actionable, and educational\n"
1015
+ "- Use your knowledge to provide insights the user might not know\n"
1016
+ "- Be culturally and regionally sensitive\n\n"
1017
+ "Round recommended_budget to nearest 100. Use appropriate currency context in your reasoning.\n"
1018
+ "Example reason: 'Your spending on Food & Drinks shows an upward trend (1800 → 2000 over 3 months), "
1019
+ "likely due to food inflation (typically 3-5% annually globally). I recommend increasing your budget by 15% "
1020
+ "to 2300 to accommodate this trend and provide a buffer for continued price increases and unexpected expenses.'\n"
1021
  )
1022
 
1023
  try: