Spaces:
Runtime error
Runtime error
Download app/config.py from digitalytics/humanizer-engine: direct link, hf CLI and curl.
- Browser
- Download file 3.3 kB
-
https://huggingface.co/spaces/digitalytics/humanizer-engine/resolve/main/app/config.py
- Command line
-
hf download hf://spaces/digitalytics/humanizer-engine/app/config.py
-
curl -L -o config.py https://huggingface.co/spaces/digitalytics/humanizer-engine/resolve/main/app/config.py
3.3 kB
| """ | |
| Application configuration loaded from environment variables. | |
| All settings are centralised here; nothing else should read os.environ directly. | |
| """ | |
| from __future__ import annotations | |
| import os | |
| from functools import lru_cache | |
| from typing import Literal | |
| from pydantic import Field | |
| from pydantic_settings import BaseSettings, SettingsConfigDict | |
| class Settings(BaseSettings): | |
| """All application configuration, loaded from .env or environment.""" | |
| model_config = SettingsConfigDict( | |
| env_file=".env", | |
| env_file_encoding="utf-8", | |
| case_sensitive=False, | |
| extra="ignore", | |
| ) | |
| # --- LLM credentials --- | |
| anthropic_api_key: str = Field(default="", description="Anthropic API key") | |
| openai_api_key: str = Field(default="", description="OpenAI API key") | |
| groq_api_key: str = Field(default="", description="Groq API key") | |
| primary_llm: Literal["claude", "openai", "groq"] = Field( | |
| default="claude", | |
| description="Which LLM to use as primary: 'claude', 'openai', or 'groq'", | |
| ) | |
| # --- Input constraints --- | |
| max_input_words: int = Field(default=5000, ge=1) | |
| min_input_words: int = Field(default=50, ge=1) | |
| # --- Output constraints --- | |
| max_expansion_percent: float = Field(default=40.0, ge=0.0, le=200.0) | |
| # --- LLM call settings --- | |
| llm_timeout_seconds: float = Field(default=8.0, gt=0.0) | |
| # --- Server settings --- | |
| workers: int = Field(default=1, ge=1) | |
| port: int = Field(default=8000, ge=1, le=65535) | |
| log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = Field( | |
| default="INFO" | |
| ) | |
| # --- Processing modes --- | |
| thorough_mode_default: bool = Field( | |
| default=False, | |
| description="Enable Stage 3 perplexity re-scoring by default", | |
| ) | |
| # --- Model identifiers --- | |
| claude_model: str = Field(default="claude-sonnet-4-20250514") | |
| openai_model: str = Field(default="gpt-4o-mini") | |
| groq_model: str = Field(default="llama-3.3-70b-versatile") | |
| # --- Local model settings --- | |
| qwen_model_id: str = Field(default="Qwen/Qwen2.5-0.5B") | |
| spacy_model: str = Field(default="en_core_web_sm") | |
| # --- Perplexity thresholds --- | |
| perplexity_high_risk_threshold: float = Field( | |
| default=30.0, | |
| description="Sentences with mean perplexity below this are 'high_risk'", | |
| ) | |
| perplexity_medium_risk_threshold: float = Field( | |
| default=60.0, | |
| description="Sentences with mean perplexity below this (and above high) are 'medium_risk'", | |
| ) | |
| # --- Burstiness thresholds --- | |
| burstiness_high_uniformity_cv: float = Field( | |
| default=0.30, | |
| description="CV below this → 'high_uniformity'", | |
| ) | |
| burstiness_moderate_uniformity_cv: float = Field( | |
| default=0.45, | |
| description="CV below this (and above high) → 'moderate_uniformity'", | |
| ) | |
| # --- Data file paths (relative to project root) --- | |
| ai_vocabulary_path: str = Field(default="app/data/ai_vocabulary.json") | |
| transition_words_path: str = Field(default="app/data/transition_words.json") | |
| heuristic_patterns_path: str = Field(default="app/data/heuristic_patterns.json") | |
| def get_settings() -> Settings: | |
| """Return a cached Settings instance (singleton).""" | |
| return Settings() | |