Spaces:
Runtime error
Runtime error
File size: 1,238 Bytes
7937092 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from src.chatbot_engine import MedicalChatbot
def test_pure_retrieval():
print("Connecting to Chroma DB (bypassing Llama 3 generation to save memory)...")
try:
bot = MedicalChatbot()
except Exception as e:
print(f"Failed to initialize chatbot: {e}")
return
question = "What are the key clinical symptoms of acute appendicitis?"
print(f"\nSearching Database for: '{question}'\n")
try:
# Bypass the LLM generation and just test the Vector Retriever directly!
docs = bot.custom_retriever.get_relevant_documents_with_filter(question)
print("====== RETRIEVAL RESULTS ======")
for i, doc in enumerate(docs):
book = doc.metadata.get('book_name', 'Unknown')
page = doc.metadata.get('page_number', 'N/A')
subject = doc.metadata.get('subject', 'General')
print(f"\n[Result {i+1}] Book: {book} | Page: {page} | Subject: {subject}")
print(f"Snippet: {doc.page_content[:400].strip()}...")
except Exception as e:
print(f"Failed to retrieve documents: {e}")
if __name__ == "__main__":
test_pure_retrieval()
|