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()