File size: 1,191 Bytes
9db766f 3a33610 f28285b 9db766f 70a2026 f28285b 9db766f |
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 |
"""Configuration settings for the API"""
import os
from pathlib import Path
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Get project root directory
API_DIR = Path(__file__).parent
PROJECT_ROOT = API_DIR.parent
# Hugging Face configuration
HUGGINGFACE_API_KEY = os.getenv("HUGGINGFACE_API_KEY", "")
HUGGINGFACE_STANCE_MODEL_ID = os.getenv("HUGGINGFACE_STANCE_MODEL_ID")
HUGGINGFACE_LABEL_MODEL_ID = os.getenv("HUGGINGFACE_LABEL_MODEL_ID")
# Use Hugging Face model ID instead of local path
STANCE_MODEL_ID = HUGGINGFACE_STANCE_MODEL_ID
LABEL_MODEL_ID = HUGGINGFACE_LABEL_MODEL_ID
# API configuration
API_TITLE = "NLP Project API"
API_DESCRIPTION = "API for various NLP models including stance detection and more"
API_VERSION = "1.0.0"
# Server configuration
HOST = os.getenv("HOST", "0.0.0.0") # Use 0.0.0.0 for Docker/Spaces
PORT = int(os.getenv("PORT", "7860")) # Default 7860 for Hugging Face Spaces
RELOAD = os.getenv("RELOAD", "False").lower() == "true" # Set to False in production
# CORS configuration
CORS_ORIGINS = ["*"] # In production, specify exact origins
CORS_CREDENTIALS = True
CORS_METHODS = ["*"]
CORS_HEADERS = ["*"]
|