hf-inference-api / app /config.py
goabonga's picture
Initial commit: HF Inference API with Gradio interface
b98ed7e unverified
raw
history blame contribute delete
800 Bytes
"""Configuration settings for the inference API."""
from functools import lru_cache
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
model_name: str = "distilbert-base-uncased-finetuned-sst-2-english"
task: str = "text-classification"
host: str = "0.0.0.0"
port: int = 8000
max_batch_size: int = 32
device: str = "cpu"
# HF Inference API settings
use_api: bool = True # True = use HF API, False = load model locally
api_token: str | None = None # HF API token (required if use_api=True)
class Config:
env_file = ".env"
env_prefix = "HF_"
@lru_cache
def get_settings() -> Settings:
"""Get cached settings instance."""
return Settings()