Update app.py
Browse files
app.py
CHANGED
|
@@ -440,8 +440,10 @@ async def tool_library_info(question, history=None, model="gpt"):
|
|
| 440 |
best_score = min(score for _, score in docs_with_scores)
|
| 441 |
print(f"RAG best_score={best_score:.3f} for: {question[:60]}")
|
| 442 |
|
| 443 |
-
|
| 444 |
-
|
|
|
|
|
|
|
| 445 |
return {"answer": "", "sources": [], "has_answer": False}
|
| 446 |
|
| 447 |
docs = [doc for doc, _ in docs_with_scores]
|
|
|
|
| 440 |
best_score = min(score for _, score in docs_with_scores)
|
| 441 |
print(f"RAG best_score={best_score:.3f} for: {question[:60]}")
|
| 442 |
|
| 443 |
+
# Threshold 1.2: Only answer from KB when docs are clearly relevant
|
| 444 |
+
# "who is Indian PM", "what is photosynthesis" etc score >1.2 against library KB
|
| 445 |
+
if best_score > 1.2:
|
| 446 |
+
print(f"RAG skipped — score {best_score:.3f} exceeds 1.2 threshold")
|
| 447 |
return {"answer": "", "sources": [], "has_answer": False}
|
| 448 |
|
| 449 |
docs = [doc for doc, _ in docs_with_scores]
|