M17idd commited on
Commit
7ec69e5
·
1 Parent(s): d32855a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -587,16 +587,22 @@ def remove_stop_words_from_lines(lines, stop_words):
587
 
588
  if query:
589
  closest_lines = find_closest_lines(query, doc_texts, stop_words, top_n=10)
590
-
591
- cleaned_closest_lines = remove_stop_words_from_lines(closest_lines, stop_words)
 
 
 
 
592
 
593
  if cleaned_closest_lines:
 
 
594
  prompt = f"""
595
  لطفاً با توجه به سؤال زیر و محتوای خطوط مرتبط، یک پاسخ نهایی حرفه‌ای، دقیق و روان تولید کن. فقط از متن خطوط مرتبط استفاده کن. اگر اطلاعات کافی در متن وجود ندارد، صادقانه اعلام کن.
596
  سوال:
597
  {query}
598
  خطوط مرتبط:
599
- {cleaned_closest_lines}
600
  پاسخ نهایی:
601
  """
602
 
@@ -609,4 +615,4 @@ if query:
609
  st.markdown(f'<div class="chat-message">{rewritten}</div>', unsafe_allow_html=True)
610
 
611
  else:
612
- st.warning("هیچ خط مرتبطی پیدا نشد.")
 
587
 
588
  if query:
589
  closest_lines = find_closest_lines(query, doc_texts, stop_words, top_n=10)
590
+
591
+ # حذف استپ‌وردها از خطوط و سپس پاکسازی نهایی متن
592
+ cleaned_closest_lines = [
593
+ clean_text(" ".join([word for word in line.split() if word not in stop_words]))
594
+ for line in closest_lines
595
+ ]
596
 
597
  if cleaned_closest_lines:
598
+ cleaned_text = "\n".join(cleaned_closest_lines[:10])
599
+
600
  prompt = f"""
601
  لطفاً با توجه به سؤال زیر و محتوای خطوط مرتبط، یک پاسخ نهایی حرفه‌ای، دقیق و روان تولید کن. فقط از متن خطوط مرتبط استفاده کن. اگر اطلاعات کافی در متن وجود ندارد، صادقانه اعلام کن.
602
  سوال:
603
  {query}
604
  خطوط مرتبط:
605
+ {cleaned_text}
606
  پاسخ نهایی:
607
  """
608
 
 
615
  st.markdown(f'<div class="chat-message">{rewritten}</div>', unsafe_allow_html=True)
616
 
617
  else:
618
+ st.warning("هیچ خط مرتبطی پیدا نشد.")