Ahmad140 commited on
Commit
dfd7ce2
Β·
verified Β·
1 Parent(s): fce760b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -28
app.py CHANGED
@@ -55,7 +55,7 @@ def classify_intent_sbert(text):
55
  OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
56
  MODEL = "google/gemini-2.0-flash-lite-preview-02-05" # free
57
 
58
- SYSTEM_PROMPT = """You are "VisionCraft AI" – a professional sales and support assistant for "Elite Visuals", a premium imagery business.
59
 
60
  Services offered:
61
  - High-end product photography (jewelry, cars, luxury goods)
@@ -65,20 +65,24 @@ Services offered:
65
  - AI-enhanced photo editing & retouching
66
  - 4K/8K video production for commercials
67
 
68
- Tone: Polite, professional, enthusiastic. Use Urdu/Hindi mix if customer does, but keep technical terms in English.
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
  Guidelines:
71
- - For pricing: give ranges (e.g., product photography PKR 15,000-25,000/session)
72
- - For contact: +92 300 1234567, email hello@elitevisuals.com, website www.elitevisuals.com
73
- - For portfolio: "Hamaare Instagram @elitevisuals ya website par samples hain"
74
- - For complaints: apologize, offer discount on next service
75
- - Never generate random legal/contract text. Stay focused on imagery.
76
- - Keep answers concise but helpful.
77
-
78
- Example:
79
- Customer: "Contact number?"
80
- You: "Sir, Elite Visuals ka contact: +92 300 1234567. Kya main aapki service mein madad kar sakta hoon?"
81
- """
82
 
83
  def call_openrouter(prompt):
84
  if not OPENROUTER_API_KEY:
@@ -106,27 +110,19 @@ def call_openrouter(prompt):
106
  def fallback_response(prompt, intent):
107
  p = prompt.lower()
108
  if intent == "greeting":
109
- return "Wa-Alaikum-Assalam! Main Elite Visuals ka assistant hoon. Aap photography, 3D rendering ya video production ki baat kar sakte hain."
110
  elif intent == "contact":
111
- return "Elite Visuals ka contact: +92 300 1234567, email: hello@elitevisuals.com, website: www.elitevisuals.com"
112
  elif intent == "pricing":
113
- return "Pricing: Product photography PKR 15,000-25,000/session, Architecture renders PKR 30,000-50,000/project, Corporate videos PKR 50,000-2,00,000 depending on length. Exact quote ke liye apni requirement bhejein."
114
  elif intent == "portfolio":
115
- return "Aap hamaare Instagram @elitevisuals ya website www.elitevisuals.com/gallery par sample dekh sakte hain."
116
  elif intent == "complaint":
117
- return "Maazrat, problem ke liye. Kya aap apna order ID bata sakte hain? Hum priority se resolve karenge aur next order par 10% discount denge."
118
  elif intent == "order_status":
119
- return "Order status check karne ke liye apna order ID aur email bhejein. Hum 24 ghante mein update karenge."
120
  else:
121
- return "Main aapki kaise madad kar sakta hoon? Hum product photography, architecture renders, corporate videos, aur drone cinematography mein specialist hain."
122
-
123
- def get_ai_response(prompt, intent):
124
- resp = call_openrouter(prompt)
125
- if resp and resp.strip() and "error" not in resp.lower():
126
- print("βœ… OpenRouter succeeded")
127
- return resp
128
- print("⚠️ OpenRouter failed, using smart fallback")
129
- return fallback_response(prompt, intent)
130
 
131
  # ---------- Firebase Helpers ----------
132
  def save_message(session_id, role, content, intent=None):
 
55
  OPENROUTER_API_KEY = os.getenv("OPENROUTER_API_KEY")
56
  MODEL = "google/gemini-2.0-flash-lite-preview-02-05" # free
57
 
58
+ SYSTEM_PROMPT = SYSTEM_PROMPT = """You are "VisionCraft AI" – a professional sales and support assistant for "Elite Visuals", a premium imagery business.
59
 
60
  Services offered:
61
  - High-end product photography (jewelry, cars, luxury goods)
 
65
  - AI-enhanced photo editing & retouching
66
  - 4K/8K video production for commercials
67
 
68
+ Tone: Polite, professional, enthusiastic. Use Urdu/Hindi mix if customer does.
69
+
70
+ **IMPORTANT OUTPUT RULE:** Always answer in bullet points (using dashes or asterisks). Never write long paragraphs. Break information into clear, short points.
71
+
72
+ Example correct output for "contact number":
73
+ - πŸ“ž Phone: +92 300 1234567
74
+ - βœ‰οΈ Email: hello@elitevisuals.com
75
+ - 🌐 Website: www.elitevisuals.com
76
+
77
+ Example for pricing:
78
+ - Product photography: PKR 15,000–25,000 per session
79
+ - Architecture renders: PKR 30,000–50,000 per project
80
+ - Corporate video: PKR 50,000–2,00,000 (depending on length)
81
 
82
  Guidelines:
83
+ - For complaints: apologize in one line, then bullet points for solution.
84
+ - Never generate random legal/contract text.
85
+ - Keep each bullet point short (max 15 words)."""
 
 
 
 
 
 
 
 
86
 
87
  def call_openrouter(prompt):
88
  if not OPENROUTER_API_KEY:
 
110
  def fallback_response(prompt, intent):
111
  p = prompt.lower()
112
  if intent == "greeting":
113
+ return "- Wa-Alaikum-Assalam! πŸ‘‹\n- Main Elite Visuals ka assistant hoon.\n- Main aapki in cheezon mein madad kar sakta hoon: product photography, 3D rendering, video production."
114
  elif intent == "contact":
115
+ return "- πŸ“ž Phone: +92 300 1234567\n- βœ‰οΈ Email: hello@elitevisuals.com\n- 🌐 Website: www.elitevisuals.com"
116
  elif intent == "pricing":
117
+ return "- πŸ“Έ Product photography: PKR 15,000–25,000/session\n- πŸ›οΈ Architecture renders: PKR 30,000–50,000/project\n- πŸŽ₯ Corporate video: PKR 50,000–2,00,000\n- πŸ’‘ Exact quote ke liye apni requirement bhejein."
118
  elif intent == "portfolio":
119
+ return "- πŸ“· Instagram: @elitevisuals\n- πŸ–₯️ Website gallery: www.elitevisuals.com/gallery\n- πŸ“‚ Sample PDF: bhej sakte hain email par"
120
  elif intent == "complaint":
121
+ return "- πŸ˜” Maazrat, issue ke liye.\n- πŸ”’ Apna order ID bhejein.\n- πŸš€ Priority resolve karenge.\n- 🎁 Next order par 10% discount."
122
  elif intent == "order_status":
123
+ return "- πŸ“¦ Order status check karne ke liye:\n β€’ Order ID\n β€’ Email address\n- ⏱️ 24 ghante mein update de denge."
124
  else:
125
+ return "- Main aapki kaise madad kar sakta hoon?\n- Humari services:\n β€’ Product photography\n β€’ Architecture renders\n β€’ Corporate videos\n β€’ Drone cinematography"
 
 
 
 
 
 
 
 
126
 
127
  # ---------- Firebase Helpers ----------
128
  def save_message(session_id, role, content, intent=None):