diff --git a/Dockerfile b/Dockerfile index faf674e..67ad11a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app RUN apt-get update && apt-get install -y curl \ && rm -rf /var/lib/apt/lists/* -COPY requirements.txt . +COPY requirements.txt pyproject.toml ./ RUN pip install --no-cache-dir -r requirements.txt COPY src/ ./src/ diff --git a/src/core/config.py b/src/core/config.py index c2ecabc..0321290 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -4,11 +4,34 @@ Following best practice of splitting config across domains. """ from enum import Enum from functools import lru_cache +from pathlib import Path from pydantic import Field, HttpUrl from pydantic_settings import BaseSettings, SettingsConfigDict +def _get_version_from_pyproject() -> str: + """ + Load version from pyproject.toml. + + Falls back to "unknown" if file cannot be read. + """ + try: + # Find pyproject.toml relative to this file + config_dir = Path(__file__).parent + pyproject_path = config_dir.parent.parent / "pyproject.toml" + + if pyproject_path.exists(): + content = pyproject_path.read_text() + for line in content.splitlines(): + if line.strip().startswith("version"): + # Parse: version = "1.0.0" + return line.split("=", 1)[1].strip().strip('"').strip("'") + except Exception: + pass + return "unknown" + + class Environment(str, Enum): """Application environment.""" DEVELOPMENT = "development" @@ -32,7 +55,7 @@ class Config(BaseSettings): # Application APP_NAME: str = "OpenAI-Compatible API" - APP_VERSION: str = "0.2.5" + APP_VERSION: str = Field(default_factory=_get_version_from_pyproject) ENVIRONMENT: Environment = Environment.DEVELOPMENT DEBUG: bool = Field(default=False, description="Debug mode") @@ -87,6 +110,20 @@ class Config(BaseSettings): description="Redis connection timeout in seconds" ) + # Library-Desk Configuration (The Librarian backend) + LIBRARY_DESK_HOST: HttpUrl = Field( + default="http://localhost:8089", + description="Library-Desk API URL" + ) + LIBRARY_DESK_API_KEY: str = Field( + default="", + description="API key for Library-Desk authentication" + ) + LIBRARY_DESK_TIMEOUT: int = Field( + default=60, + description="Library-Desk request timeout in seconds" + ) + # Logging LOG_LEVEL: str = Field(default="INFO", description="Logging level") ENABLE_BENCHMARKS: bool = Field(default=True, description="Enable performance benchmarking")