Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -60,7 +60,7 @@ def search_similar_texts(query, k):
|
|
| 60 |
k (int): Number of results to return.
|
| 61 |
|
| 62 |
Returns:
|
| 63 |
-
str: Formatted search results
|
| 64 |
"""
|
| 65 |
if not query or not query.strip():
|
| 66 |
return "Error: Query cannot be empty."
|
|
@@ -76,12 +76,11 @@ def search_similar_texts(query, k):
|
|
| 76 |
if not docs:
|
| 77 |
return "No results found."
|
| 78 |
|
| 79 |
-
# Format results
|
| 80 |
results = []
|
| 81 |
for i, doc in enumerate(docs[:k]): # Ensure we return at most k
|
| 82 |
text = doc.metadata.get("text", "No text available")
|
| 83 |
-
|
| 84 |
-
results.append(f"Result {i+1}:\nText: {text}\nScore: {score:.4f}\n")
|
| 85 |
|
| 86 |
return "\n".join(results) or "No results found."
|
| 87 |
|
|
|
|
| 60 |
k (int): Number of results to return.
|
| 61 |
|
| 62 |
Returns:
|
| 63 |
+
str: Formatted search results without similarity scores.
|
| 64 |
"""
|
| 65 |
if not query or not query.strip():
|
| 66 |
return "Error: Query cannot be empty."
|
|
|
|
| 76 |
if not docs:
|
| 77 |
return "No results found."
|
| 78 |
|
| 79 |
+
# Format results without similarity scores
|
| 80 |
results = []
|
| 81 |
for i, doc in enumerate(docs[:k]): # Ensure we return at most k
|
| 82 |
text = doc.metadata.get("text", "No text available")
|
| 83 |
+
results.append(f"Result {i+1}:\nText: {text}\n")
|
|
|
|
| 84 |
|
| 85 |
return "\n".join(results) or "No results found."
|
| 86 |
|