Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -486,16 +486,16 @@ def retrieve_context(question: str, chatbot_history: List[List[str]], k: int = 2
|
|
| 486 |
]
|
| 487 |
|
| 488 |
# Kullanıcı sorgusu, geçmiş sorguları ve tüm anahtar kelimeleri birleştirerek tek bir arama metni oluştur
|
| 489 |
-
combined_query_text = f"{question} {' '.join(history_queries)}"
|
| 490 |
-
|
| 491 |
# Fazla boşlukları temizleyelim
|
| 492 |
combined_query_text = ' '.join(combined_query_text.split())
|
| 493 |
|
| 494 |
try:
|
| 495 |
query_embedding = embedder.encode([combined_query_text], convert_to_numpy=True).astype(np.float32)
|
| 496 |
D, I = index.search(query_embedding, k)
|
| 497 |
-
|
| 498 |
-
retrieved_texts = [
|
| 499 |
unique_retrieved_texts = list(dict.fromkeys(retrieved_texts))
|
| 500 |
context_text = "\n".join(unique_retrieved_texts)
|
| 501 |
return unique_retrieved_texts, context_text # Hem liste hem de birleştirilmiş metni döndür
|
|
|
|
| 486 |
]
|
| 487 |
|
| 488 |
# Kullanıcı sorgusu, geçmiş sorguları ve tüm anahtar kelimeleri birleştirerek tek bir arama metni oluştur
|
| 489 |
+
combined_query_text = f"{question} {' '.join(history_queries)} {' '.join(montag_identity_keywords)} {' '.join(general_book_keywords)}"
|
| 490 |
+
|
| 491 |
# Fazla boşlukları temizleyelim
|
| 492 |
combined_query_text = ' '.join(combined_query_text.split())
|
| 493 |
|
| 494 |
try:
|
| 495 |
query_embedding = embedder.encode([combined_query_text], convert_to_numpy=True).astype(np.float32)
|
| 496 |
D, I = index.search(query_embedding, k)
|
| 497 |
+
|
| 498 |
+
retrieved_texts = [p for i in I[0] if i < len(paragraphs) for p in [paragraphs[i]] if p not in previous_paragraphs]
|
| 499 |
unique_retrieved_texts = list(dict.fromkeys(retrieved_texts))
|
| 500 |
context_text = "\n".join(unique_retrieved_texts)
|
| 501 |
return unique_retrieved_texts, context_text # Hem liste hem de birleştirilmiş metni döndür
|