-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_and_run.py
More file actions
102 lines (84 loc) · 3 KB
/
setup_and_run.py
File metadata and controls
102 lines (84 loc) · 3 KB
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
#!/usr/bin/env python3
"""
Quick start script for ChatGPT Clone
This script helps set up and run the application with guided setup.
"""
import os
import sys
import subprocess
from pathlib import Path
def check_python_version():
"""Check if Python version is compatible"""
if sys.version_info < (3, 8):
print("❌ Python 3.8 or higher is required")
print(f"Current version: {sys.version}")
return False
print(f"✅ Python {sys.version.split()[0]} detected")
return True
def install_requirements():
"""Install required packages"""
print("📦 Installing requirements...")
try:
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
print("✅ Requirements installed successfully")
return True
except subprocess.CalledProcessError:
print("❌ Failed to install requirements")
return False
def setup_env_file():
"""Setup environment file with API key"""
env_file = Path(".env")
if env_file.exists():
with open(env_file, 'r') as f:
content = f.read()
if "your_deepseek_api_key_here" not in content:
print("✅ .env file already configured")
return True
print("\n🔑 OpenRouter API Key Setup")
print("You need an OpenRouter API key with DeepSeek R1 access to use this application.")
print("Get one from: https://openrouter.ai/")
print()
api_key = input("Enter your OpenRouter API key (or press Enter to use demo mode): ").strip()
if not api_key:
api_key = "demo_key_placeholder"
print("⚠️ Demo mode: Some features may not work without a valid API key")
with open(env_file, 'w') as f:
f.write(f"DEEPSEEK_API_KEY={api_key}\n")
f.write(f"DEEPSEEK_API_URL=https://openrouter.ai/api/v1/chat/completions\n")
print("✅ .env file created")
return True
def start_server():
"""Start the FastAPI server"""
print("\n🚀 Starting ChatGPT Clone server...")
print("Server will be available at: http://localhost:8000")
print("Press Ctrl+C to stop the server")
print("-" * 50)
try:
import uvicorn
from main import app
uvicorn.run(app, host="0.0.0.0", port=8000)
except KeyboardInterrupt:
print("\n\n👋 Server stopped. Thanks for using ChatGPT Clone!")
except ImportError:
print("❌ FastAPI/Uvicorn not properly installed")
return False
except Exception as e:
print(f"❌ Error starting server: {e}")
return False
def main():
"""Main setup and run function"""
print("🤖 ChatGPT Clone with DeepSeek R1 via OpenRouter")
print("=" * 40)
# Check Python version
if not check_python_version():
return
# Install requirements
if not install_requirements():
return
# Setup environment
if not setup_env_file():
return
# Start server
start_server()
if __name__ == "__main__":
main()