Vertical.ai / backend /scripts /test_rag.py
Abhisingh-18's picture
Mirror of github.com/Abhisingh18/Vertical.ai
1f7ead8 verified
Raw
History Blame Contribute Delete
1.11 kB
import sys
import os
# Add project root to path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
from backend.app.services.rag import generate_answer
def test_rag():
print("Testing RAG Generation with Gemini...")
query = "What causes backend crashes?"
context_chunks = [
{"doc_id": "doc1", "text": "Backend crashes are often caused by memory leaks and lack of resource isolation."},
{"doc_id": "doc2", "text": "Using Docker with memory limits can prevent single container crashes from affecting the host."}
]
try:
answer = generate_answer(query, context_chunks)
print("--- Generated Answer ---")
print(answer)
print("--- End Answer ---")
if "Internal Error" in answer or "encountered an error" in answer:
print("FAILED: RAG returned error.")
else:
print("SUCCESS: RAG generation working.")
except Exception as e:
print(f"EXCEPTION: {e}")
if __name__ == "__main__":
test_rag()