""" Setup script for RAG Evaluation Framework """ import subprocess import sys from pathlib import Path def install_dependencies(): """Install required dependencies""" print("Installing dependencies...") print("=" * 60) requirements_file = Path(__file__).parent / "requirements.txt" if not requirements_file.exists(): print(f"Error: requirements.txt not found at {requirements_file}") return False try: subprocess.check_call([ sys.executable, "-m", "pip", "install", "-r", str(requirements_file) ]) print("\n✓ Dependencies installed successfully!") return True except subprocess.CalledProcessError as e: print(f"\n✗ Failed to install dependencies: {e}") return False def verify_installation(): """Verify that all modules can be imported""" print("\nVerifying installation...") print("=" * 60) modules_to_test = [ ("ragas", "RAGAS"), ("langchain", "LangChain"), ("pymysql", "PyMySQL"), ("yaml", "PyYAML"), ("dotenv", "python-dotenv"), ("requests", "requests"), ] all_ok = True for module_name, display_name in modules_to_test: try: __import__(module_name) print(f"✓ {display_name}") except ImportError: print(f"✗ {display_name} - NOT INSTALLED") all_ok = False return all_ok def main(): """Main setup function""" print("\n" + "=" * 60) print("RAG Evaluation Framework - Setup") print("=" * 60) # Install dependencies if not install_dependencies(): print("\n⚠ Setup failed!") return 1 # Verify installation if not verify_installation(): print("\n⚠ Some modules failed to install!") return 1 print("\n" + "=" * 60) print("✅ Setup completed successfully!") print("=" * 60) print("\nNext steps:") print("1. Copy config.example.yaml to config.yaml") print("2. Update config.yaml with your settings") print("3. Run: python test_framework.py") print("4. Run: python example.py") return 0 if __name__ == "__main__": sys.exit(main())