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