-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.py
97 lines (79 loc) · 2.57 KB
/
install.py
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
#!/usr/bin/env python3
"""
install.py - Installation script for LLM Development Environment
"""
import subprocess
import sys
import os
from pathlib import Path
import shutil
def check_prerequisites():
"""Check if required tools are installed."""
requirements = ['python', 'pip', 'git', 'docker']
for req in requirements:
if shutil.which(req) is None:
print(f"Error: {req} is not installed. Please install it first.")
sys.exit(1)
def setup_virtual_environment():
"""Create and activate virtual environment."""
subprocess.run([sys.executable, '-m', 'venv', 'venv'], check=True)
# Activate virtual environment
if sys.platform == 'win32':
activate_script = 'venv\\Scripts\\activate'
else:
activate_script = 'source venv/bin/activate'
print(f"To activate the virtual environment, run: {activate_script}")
def install_requirements():
"""Install required Python packages."""
subprocess.run([
sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'
], check=True)
def setup_project_structure():
"""Create project directory structure."""
directories = [
'config',
'data',
'output',
'logs',
'prompts',
'src'
]
for directory in directories:
Path(directory).mkdir(exist_ok=True)
def create_env_template():
"""Create .env template file."""
env_content = """
# API Keys
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
PINECONE_API_KEY=your_pinecone_api_key
# Configuration
DEBUG=false
LOG_LEVEL=INFO
# Vector Store Settings
VECTOR_STORE_PATH=./data/vector_store
"""
with open('.env.template', 'w') as f:
f.write(env_content.strip())
def main():
"""Main installation function."""
try:
print("Starting LLM Development Environment installation...")
check_prerequisites()
setup_project_structure()
setup_virtual_environment()
install_requirements()
create_env_template()
print("\nInstallation completed successfully!")
print("\nNext steps:")
print("1. Copy .env.template to .env and fill in your API keys")
print("2. Activate the virtual environment")
print("3. Run 'python main.py setup' to initialize the environment")
except subprocess.CalledProcessError as e:
print(f"Error during installation: {e}")
sys.exit(1)
except Exception as e:
print(f"Unexpected error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()