1
0

install.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/env python3
  2. """
  3. InnoCore AI - Installation Script
  4. 研创·智核 - 安装脚本
  5. """
  6. import subprocess
  7. import sys
  8. from pathlib import Path
  9. def install_core_deps():
  10. """Install only core dependencies"""
  11. print("Installing core dependencies...")
  12. core_deps = [
  13. "fastapi==0.104.1",
  14. "uvicorn[standard]==0.24.0",
  15. "python-multipart==0.0.6",
  16. "python-dotenv==1.0.0",
  17. "pydantic==2.5.0",
  18. "httpx==0.25.2",
  19. "requests==2.31.0"
  20. ]
  21. for dep in core_deps:
  22. try:
  23. print(f" Installing {dep}...")
  24. subprocess.check_call([sys.executable, "-m", "pip", "install", dep])
  25. print(f" [OK] {dep} installed")
  26. except subprocess.CalledProcessError as e:
  27. print(f" [ERROR] Failed to install {dep}: {e}")
  28. return False
  29. print("[OK] Core dependencies installed successfully")
  30. return True
  31. def create_env_file():
  32. """Create .env file"""
  33. env_file = Path(".env")
  34. if not env_file.exists():
  35. print("Creating .env file...")
  36. env_content = """# InnoCore AI Configuration
  37. OPENAI_API_KEY=your_openai_api_key_here
  38. DATABASE_URL=sqlite:///./innocore.db
  39. SECRET_KEY=your_secret_key_here_change_this_in_production
  40. DEBUG=True
  41. """
  42. env_file.write_text(env_content)
  43. print("[OK] .env file created")
  44. print("[WARNING] Please edit .env file and add your OpenAI API key")
  45. else:
  46. print("[OK] .env file already exists")
  47. def create_directories():
  48. """Create necessary directories"""
  49. dirs = ["data", "logs"]
  50. for dir_path in dirs:
  51. Path(dir_path).mkdir(exist_ok=True)
  52. print("[OK] Directories created")
  53. def main():
  54. print("InnoCore AI - Installation")
  55. print("=" * 40)
  56. # Install core dependencies
  57. if not install_core_deps():
  58. print("[ERROR] Installation failed")
  59. return
  60. # Create environment file
  61. create_env_file()
  62. # Create directories
  63. create_directories()
  64. print("\n[SUCCESS] Installation completed!")
  65. print("Next steps:")
  66. print("1. Edit .env file and add your OpenAI API key")
  67. print("2. Run: python run.py")
  68. print("3. Open: http://localhost:8000")
  69. if __name__ == "__main__":
  70. main()