Spaces:
Sleeping
Sleeping
| """Verify that the project setup is complete and correct.""" | |
| import os | |
| import sys | |
| from pathlib import Path | |
| def check_file(filepath, required=True): | |
| """Check if a file exists.""" | |
| if os.path.exists(filepath): | |
| print(f"β {filepath}") | |
| return True | |
| else: | |
| status = "β" if required else "β οΈ" | |
| print(f"{status} {filepath} {'(REQUIRED)' if required else '(optional)'}") | |
| return not required | |
| def check_env_vars(): | |
| """Check if .env file has required variables.""" | |
| if not os.path.exists('.env'): | |
| print("β .env file not found!") | |
| return False | |
| required_vars = ['GEMINI_API_KEY', 'SERPAPI_API_KEY'] | |
| optional_vars = ['TELEGRAM_BOT_TOKEN', 'WHATSAPP_ACCESS_TOKEN'] | |
| with open('.env', 'r') as f: | |
| content = f.read() | |
| print("\nπ Environment Variables:") | |
| all_good = True | |
| for var in required_vars: | |
| if var in content and 'your_' not in content.split(var)[1].split('\n')[0]: | |
| print(f"β {var} is set") | |
| else: | |
| print(f"β {var} is NOT set (REQUIRED)") | |
| all_good = False | |
| for var in optional_vars: | |
| if var in content and 'your_' not in content.split(var)[1].split('\n')[0]: | |
| print(f"β {var} is set") | |
| else: | |
| print(f"β οΈ {var} is not set (optional)") | |
| return all_good | |
| def check_dependencies(): | |
| """Check if key dependencies are installed.""" | |
| print("\nπ¦ Dependencies:") | |
| deps = { | |
| 'fastapi': True, | |
| 'uvicorn': True, | |
| 'gradio': True, | |
| 'langchain': True, | |
| 'google.generativeai': True, | |
| 'telegram': False, | |
| 'serpapi': True, | |
| } | |
| all_good = True | |
| for dep, required in deps.items(): | |
| try: | |
| __import__(dep) | |
| print(f"β {dep}") | |
| except ImportError: | |
| status = "β" if required else "β οΈ" | |
| print(f"{status} {dep} {'(REQUIRED)' if required else '(optional)'}") | |
| if required: | |
| all_good = False | |
| return all_good | |
| def main(): | |
| """Run all verification checks.""" | |
| print("="*60) | |
| print("π Rural E-commerce Bot - Setup Verification") | |
| print("="*60 + "\n") | |
| print("π Core Files:") | |
| files_ok = all([ | |
| check_file('api.py'), | |
| check_file('agent.py'), | |
| check_file('database.py'), | |
| check_file('tools.py'), | |
| check_file('config.py'), | |
| check_file('main.py'), | |
| check_file('gradio_ui.py'), | |
| check_file('requirements.txt'), | |
| check_file('.env'), | |
| ]) | |
| print("\nπ Channel Handlers:") | |
| handlers_ok = all([ | |
| check_file('channels/whatsapp_handler.py'), | |
| check_file('channels/telegram_handler.py'), | |
| ]) | |
| print("\nπ Utilities:") | |
| utils_ok = all([ | |
| check_file('utils/error_handler.py'), | |
| check_file('scripts/setup.py'), | |
| ]) | |
| print("\nπ Documentation:") | |
| docs_ok = all([ | |
| check_file('README.md'), | |
| check_file('QUICKSTART.md'), | |
| check_file('DEPLOYMENT.md'), | |
| check_file('PROJECT_SUMMARY.md'), | |
| ]) | |
| print("\nπ Tests:") | |
| tests_ok = check_file('tests/test_agent.py') | |
| env_ok = check_env_vars() | |
| deps_ok = check_dependencies() | |
| print("\n" + "="*60) | |
| print("π Verification Summary") | |
| print("="*60) | |
| results = { | |
| "Core Files": files_ok, | |
| "Channel Handlers": handlers_ok, | |
| "Utilities": utils_ok, | |
| "Documentation": docs_ok, | |
| "Tests": tests_ok, | |
| "Environment Variables": env_ok, | |
| "Dependencies": deps_ok, | |
| } | |
| for category, status in results.items(): | |
| icon = "β " if status else "β" | |
| print(f"{icon} {category}") | |
| all_ok = all(results.values()) | |
| print("\n" + "="*60) | |
| if all_ok: | |
| print("π All checks passed! Your setup is complete.") | |
| print("="*60) | |
| print("\nπ Next steps:") | |
| print("1. Run: python main.py --mode all") | |
| print("2. Open: http://localhost:7860") | |
| print("3. Test with: 'I need a mobile under βΉ5000'") | |
| print("\n⨠Happy coding!\n") | |
| return 0 | |
| else: | |
| print("β οΈ Some checks failed. Please fix the issues above.") | |
| print("="*60) | |
| print("\nπ‘ Quick fixes:") | |
| print("- Missing files: Check if you're in the right directory") | |
| print("- .env not set: Run 'python scripts/setup.py'") | |
| print("- Dependencies: Run 'pip install -r requirements.txt'") | |
| print() | |
| return 1 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |