Spaces:
Runtime error
Runtime error
File size: 2,716 Bytes
407b660 | 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 | # #!/usr/bin/env python3
# """
# Startup script for the Document Research & Theme Identification API
# """
# import os
# import sys
# from pathlib import Path
# def check_environment():
# """Check if all required environment variables and files exist"""
# print("π Checking environment...")
# # Check for .env file
# if not Path(".env").exists():
# print("β οΈ .env file not found. Please create one based on .env.template")
# print(" You can copy: cp .env.template .env")
# return False
# # Check for Groq API key
# from dotenv import load_dotenv
# load_dotenv()
# if not os.getenv("GROQ_API_KEY"):
# print("β οΈ GROQ_API_KEY not found in environment variables")
# print(" Theme synthesis will not be available")
# print(" Get your API key from: https://console.groq.com/")
# return False
# print("β
Environment check passed!")
# return True
# def install_dependencies():
# """Install required dependencies"""
# print("π¦ Installing dependencies...")
# os.system("pip install -r requirements.txt")
# print("β
Dependencies installed!")
# def create_directories():
# """Create necessary directories"""
# print("π Creating directories...")
# directories = ["./data", "./data/chroma_db", "./data/uploads"]
# for directory in directories:
# Path(directory).mkdir(parents=True, exist_ok=True)
# print("β
Directories created!")
# def main():
# """Main startup function"""
# print("π Starting Document Research & Theme Identification API...")
# print("=" * 60)
# # Create directories
# create_directories()
# # Install dependencies
# if "--install" in sys.argv:
# install_dependencies()
# # Check environment
# env_ok = check_environment()
# print("=" * 60)
# if env_ok:
# print("π Setup complete! Starting the API server...")
# print("π API will be available at: http://localhost:8000")
# print("π API documentation at: http://localhost:8000/docs")
# print()
# # Start the API
# if "--dev" in sys.argv:
# os.system("uvicorn api:app --host 0.0.0.0 --port 8000 --reload")
# else:
# os.system("uvicorn api:app --host 0.0.0.0 --port 8000")
# else:
# print("β Setup incomplete. Please fix the issues above and try again.")
# sys.exit(1)
# if __name__ == "__main__":
# import uvicorn
# uvicorn.run("api:app", host="0.0.0.0", port=8000, reload=True) |