FilozofMuhendis
Initial model upload - Industrial Cost Calculation Chatbot
8223b74 verified
import os
import sys
import subprocess
def check_environment():
"""Check if the environment is properly set up"""
print("Checking environment...")
# Check if .env file exists
if not os.path.exists(".env"):
print("Warning: .env file not found. Creating from .env.example...")
if os.path.exists(".env.example"):
with open(".env.example", "r") as example_file:
with open(".env", "w") as env_file:
env_file.write(example_file.read())
print(".env file created successfully.")
else:
print("Error: .env.example file not found. Please create a .env file manually.")
return False
# Check if required packages are installed
try:
import fastapi
import uvicorn
import langchain
import transformers
import torch
print("All required packages are installed.")
except ImportError as e:
print(f"Error: Missing required package: {e}")
print("Please run: pip install -r requirements.txt")
return False
return True
def start_application():
"""Start the FastAPI application"""
if not check_environment():
print("Environment check failed. Please fix the issues and try again.")
return
print("\nStarting the application...")
print("The application will be available at http://localhost:8000")
print("Press Ctrl+C to stop the application.")
# Start the application using uvicorn
try:
subprocess.run([sys.executable, "-m", "uvicorn", "app.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000"])
except KeyboardInterrupt:
print("\nApplication stopped.")
if __name__ == "__main__":
start_application()