Download config.py from JatinAutonomousLabs/PDF_analyst: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/spaces/JatinAutonomousLabs/PDF_analyst/resolve/main/config.py
- Command line
-
hf download hf://spaces/JatinAutonomousLabs/PDF_analyst/config.py
-
curl -L -o config.py https://huggingface.co/spaces/JatinAutonomousLabs/PDF_analyst/resolve/main/config.py
1.91 kB
| # config.py - Configuration management for PDF Analysis & Orchestrator | |
| import os | |
| from pathlib import Path | |
| class Config: | |
| """Centralized configuration for the PDF Analysis Orchestrator""" | |
| # OpenAI Configuration | |
| OPENAI_MODEL = os.environ.get("OPENAI_MODEL", "gpt-4") | |
| OPENAI_TEMPERATURE = float(os.environ.get("OPENAI_TEMPERATURE", "0.2")) | |
| OPENAI_MAX_TOKENS = int(os.environ.get("OPENAI_MAX_TOKENS", "1000")) | |
| # Document Processing | |
| CHUNK_SIZE = int(os.environ.get("CHUNK_SIZE", "15000")) | |
| CHUNK_OVERLAP = int(os.environ.get("CHUNK_OVERLAP", "1000")) | |
| MAX_FILE_SIZE_MB = int(os.environ.get("ANALYSIS_MAX_UPLOAD_MB", "50")) | |
| # Caching | |
| CACHE_ENABLED = os.environ.get("CACHE_ENABLED", "true").lower() == "true" | |
| CACHE_TTL_HOURS = int(os.environ.get("CACHE_TTL_HOURS", "24")) | |
| # Session Management | |
| SESSION_DIR = os.environ.get("ANALYSIS_SESSION_DIR", "/tmp/analysis_sessions") | |
| # UI Configuration | |
| SERVER_NAME = os.environ.get("SERVER_NAME", "0.0.0.0") | |
| SERVER_PORT = int(os.environ.get("PORT", "7860")) | |
| # Export Settings | |
| EXPORT_DIR = os.environ.get("EXPORT_DIR", "/tmp/analysis_exports") | |
| SUPPORTED_EXPORT_FORMATS = ["txt", "json", "pdf"] | |
| # Custom Prompts | |
| PROMPTS_DIR = os.environ.get("PROMPTS_DIR", "/tmp/analysis_prompts") | |
| def ensure_directories(cls): | |
| """Ensure all required directories exist""" | |
| directories = [ | |
| cls.SESSION_DIR, | |
| cls.EXPORT_DIR, | |
| cls.PROMPTS_DIR | |
| ] | |
| for directory in directories: | |
| Path(directory).mkdir(parents=True, exist_ok=True) | |
| def get_chunk_size_for_text(cls, text_length: int) -> int: | |
| """Determine appropriate chunk size based on text length""" | |
| if text_length <= cls.CHUNK_SIZE: | |
| return text_length | |
| return cls.CHUNK_SIZE | |