Spaces:
Sleeping
Sleeping
File size: 4,644 Bytes
75788a5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | """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())
|