Rezuwan commited on
Commit
67c547a
·
verified ·
1 Parent(s): a414841

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -19
app.py CHANGED
@@ -262,45 +262,48 @@ def custom_unmad_satirical_bot(message, history, top_k=3, lambda_param=0.6):
262
  if cleaned_contexts:
263
  top_contexts = "\n\n---\n\n".join(cleaned_contexts)
264
  else:
265
- top_contexts = "প্রাসঙ্গিক বাংলা তথ্য পাওয়া যায়নি।"
266
 
267
  # Add metadata about source diversity (optional)
268
  source_info = []
269
  for i, doc in enumerate(docs, 1):
270
- source = doc['metadata'].get('source', 'অজানা উৎস')
271
- page = doc['metadata'].get('page', 'অজানা পৃষ্ঠা')
272
  # Clean source info too
273
  if not re.search(r'[a-zA-Z]', str(source)): # Only if source doesn't contain English
274
  source_info.append(f"[{i}] {source} - {page}")
275
 
276
- source_context = "উৎস: " + " | ".join(source_info[:3]) if source_info else ""
277
  else:
278
- top_contexts = "কোন প্রাসঙ্গিক তথ্য পাওয়া যায়নি।"
279
  source_context = ""
280
 
281
  # Prepare system prompt
282
  system_prompt = """
283
- তুমি 'উন্মাদ' ম্যাগাজিনের একজন পুরানো ব্যঙ্গাত্মক লেখক। তোমার কাজ হলো ব্যবহারকারীর প্রশ্ন শুনে স্যাটায়ার, কটাক্ষ, রসিকতা, ঠাট্টা, আর একটু জ্ঞান মিশিয়ে উত্তর দেওয়া — যাতে লোক হাসে, চিন্তা করে, আবার নতুন কিছু শিখে।
284
- তুমি কখনোই একদম সোজাসাপ্টা উত্তর দেবে নাবরং একটু অভিনয় করে, অবাক হয়ে, ঠাট্টা করে, খোঁচা মেরে দেবে।
285
 
286
- **এই নির্দেশনাগুলো অবশ্যই মেনে চলবে - কোন ব্যতিক্রম নেই**
287
- ১। কোন ইমোজি (EMOJI) ব্যবহার করবে না - একটিও না।
288
- ২। কোন ইংরেজি টেক্সট ব্যবহার করবে না - একটি শব্দও না।
289
- ৩। কোন ইংরেজি সংখ্যা বা চিহ্ন লিখবে না (যেমন: PDF, URL, www, .com, scanned by, found in ইত্যাদি)।
290
- ৪। প্রসঙ্গের মধ্যে যেসব ইংরেজি টেক্সট, স্ক্যান ওয়াটারমার্ক, ওয়েবসাইট নাম, বা প্রযুক্তিগত শব্দ আছে সেগুলো একেবারেই উল্লেখ করবে না।
291
- ৫। শুধুমাত্র বাংলা ভাষায় লেখা বিষয়বস্তু ব্যবহার করবে।
292
- ৬। যদি প্রসঙ্গে কোন বাংলা কন্টেন্ট না থাকে, তাহলে নিজের সাধারণ জ্ঞান দিয়ে উত্তর দেবে।
293
- ৭। বিভিন্ন উৎস থেকে তথ্য মিলিয়ে একটি সমন্বিত উত্তর দেবে।
294
- ৮। কোন ধরনের ওয়েবসাইট বা পিডিএফ রেফারেন্স দেবে না।
 
 
 
295
  """
296
 
297
  user_prompt = f"""
298
- প্রসঙ্গ (বিভিন্ন উৎস থেকে সংগৃহীত):
299
  {top_contexts}
300
 
301
- প্রশ্ন: {message}
302
 
303
- নির্দেশনা: উপরের প্রসঙ্গ থেকে শুধুমাত্র বাংলা ভাষার বিষয়বস্তু ব্যবহার করে উন্মাদ ম্যাগাজিনের স্টাইলে উত্তর দাও। কোন ইংরেজি শব্দ, ইমোজি, বা স্ক্যান ওয়াটারমার্ক উল্লেখ করবে না। সম্পূর্ণ বাংলায় ব্যঙ্গাত্মক মজার উত্তর লেখো।
304
  """
305
 
306
  # Generate response using OpenAI
 
262
  if cleaned_contexts:
263
  top_contexts = "\n\n---\n\n".join(cleaned_contexts)
264
  else:
265
+ top_contexts = "No relevant information were found"
266
 
267
  # Add metadata about source diversity (optional)
268
  source_info = []
269
  for i, doc in enumerate(docs, 1):
270
+ source = doc['metadata'].get('source', 'Unknown source')
271
+ page = doc['metadata'].get('page', 'Unnown page')
272
  # Clean source info too
273
  if not re.search(r'[a-zA-Z]', str(source)): # Only if source doesn't contain English
274
  source_info.append(f"[{i}] {source} - {page}")
275
 
276
+ source_context = "Source: " + " | ".join(source_info[:3]) if source_info else ""
277
  else:
278
+ top_contexts = "No relevant information were found"
279
  source_context = ""
280
 
281
  # Prepare system prompt
282
  system_prompt = """
283
+ You are an old satirical writer from the magazine *Unmad*.
284
+ Your job is to listen to the user’s questions and respond with **satire, sarcasm, humor, teasing, and a bit of wisdom** so that people laugh, think, and maybe learn something new.
285
 
286
+ You must **never** give a direct or plain answer — instead, respond playfully, with surprise, mockery, or witty jabs.
287
+
288
+ **You must strictly follow these rules no exceptions:**
289
+
290
+ 1. Do **not** use any emojis not even one.
291
+ 2. Do **not** use any English text — not even a single word.
292
+ 3. Do **not** use English numbers or symbols (for example: PDF, URL, www, .com, scanned by, found in, etc.).
293
+ 4. Do **not** mention any English text, scan watermarks, website names, or technical terms that appear in the context.
294
+ 5. Use **only Bangla (Bengali)** in your responses.
295
+ 6. If there’s no Bangla content in the context, respond using your own general knowledge.
296
+ 7. Combine information from various sources to create a unified, coherent answer.
297
+ 8. Do **not** provide any website or PDF references of any kind.
298
  """
299
 
300
  user_prompt = f"""
301
+ Context (collected from various sources):
302
  {top_contexts}
303
 
304
+ Question: {message}
305
 
306
+ Instruction: Using only the Bengali-language content from the context above, respond in the style of Unmad magazine. Do not use any English words, emojis, or scan watermarks. Write a fully Bengali response that is satirical and humorous in tone.
307
  """
308
 
309
  # Generate response using OpenAI