webcraft-ai-backend / deploy_tmp /test_rag_integration.py
3ssem0
fix: configuration error - aligned entry point to app.py and enforced LF/BOM-less encoding
ec47953
Raw
History Blame Contribute Delete
1.51 kB
import os
import sys
# Add current directory to path so imports work
current_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(current_dir)
from ai_planner import get_planner
def test_integration():
print("πŸš€ Initializing AI Planner (with RAG)...")
try:
planner = get_planner()
print("βœ… Planner initialized.")
# Check if librarian is there
if hasattr(planner, 'librarian'):
print(f"βœ… RAG Librarian found with {len(planner.librarian.index)} blocks.")
else:
print("❌ RAG Librarian NOT found in planner.")
return
# key test: RETRIEVAL
prompt = "Create a login form"
print(f"\nπŸ§ͺ Testing Retrieval for: '{prompt}'")
# We can't easily mock the API call without credentials or mocking,
# but we can check if retrieve works
relevant = planner.librarian.retrieve(prompt)
print(f"πŸ“š Retrieved blocks: {relevant}")
if 'basic_form_wrapper' in relevant or 'form' in str(relevant):
print("βœ… Retrieval logic looks correct.")
else:
print("⚠️ Retrieval might be fuzzy, but ran without error.")
print("\nβœ… Integration Test Passed!")
except Exception as e:
print(f"❌ Integration Test Failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_integration()