Download app/config.py from Stoic-2910/acpc-testing-third: direct link, hf CLI and curl.
- Browser
- Download file 3.18 kB
-
https://huggingface.co/spaces/Stoic-2910/acpc-testing-third/resolve/main/app/config.py
- Command line
-
hf download hf://spaces/Stoic-2910/acpc-testing-third/app/config.py
-
curl -L -o config.py https://huggingface.co/spaces/Stoic-2910/acpc-testing-third/resolve/main/app/config.py
3.18 kB
| from pydantic_settings import BaseSettings | |
| from pydantic import Field, field_validator | |
| class Settings(BaseSettings): | |
| """Application settings — validated at startup from environment variables.""" | |
| model_config = { | |
| "env_file": ".env", | |
| "env_file_encoding": "utf-8", | |
| "extra": "ignore", | |
| "populate_by_name": True, | |
| } | |
| # OpenAI / OpenRouter | |
| openai_api_key: str = Field(alias="OPENROUTER_API_KEY", default="") | |
| openai_api_base: str = Field(default="https://openrouter.ai/api/v1") | |
| # Qdrant | |
| qdrant_url: str = Field(default="") | |
| qdrant_api_key: str = Field(default="") | |
| collection_name: str = Field(default="ld_chatbot_main") | |
| vector_name: str = Field(default="text-dense") | |
| sparse_vector_name: str = Field(default="text-sparse-new") | |
| # Models | |
| embedding_model: str = Field(default="text-embedding-3-small") | |
| sparse_embedding_model: str = Field(default="Qdrant/bm25") | |
| llm_model: str = Field(default="openai/gpt-5.4-mini") | |
| query_gen_model: str = Field(default="openai/gpt-5.4-mini") | |
| reranker_model: str = Field(default="rerank-english-v3.0") | |
| # Cohere | |
| cohere_api_key: str = Field(default="") | |
| # Sarvam | |
| sarvam_api_key: str = Field(default="") | |
| sarvam_api_url: str = Field(default="https://api.sarvam.ai/speech-to-text") | |
| # Langfuse | |
| langfuse_public_key: str = Field(default="") | |
| langfuse_secret_key: str = Field(default="") | |
| langfuse_host: str = Field(default="https://cloud.langfuse.com") | |
| # Retrieval parameters | |
| retrieval_top_k: int = Field(default=15) | |
| rerank_top_n: int = Field(default=5) | |
| # Agent parameters | |
| max_retrieval_retries: int = Field(default=2) | |
| confidence_threshold: float = Field(default=0.2) | |
| # Memory / session | |
| max_conversation_messages: int = Field(default=20) | |
| max_context_tokens: int = Field(default=6000) | |
| session_ttl_minutes: int = Field(default=30) | |
| # Security | |
| ingest_api_key: str = Field(default="") | |
| ingest_base_dir: str = Field(default="") | |
| allowed_origins: str = Field(default="http://localhost:5173,http://localhost:3000") | |
| def parse_allowed_origins(cls, v): | |
| # Keep as comma-separated string — split where needed (e.g. in main.py CORS) | |
| if isinstance(v, list): | |
| return ",".join(v) | |
| return v | |
| def allowed_origins_list(self) -> list[str]: | |
| """Return allowed_origins as a list for CORS middleware.""" | |
| return [o.strip() for o in self.allowed_origins.split(",") if o.strip()] | |
| # Chunk parameters (for ingestion — must match existing collection) | |
| chunk_size: int = Field(default=512) | |
| chunk_overlap: int = Field(default=64) | |
| # Fallback response (never LLM-generated) | |
| fallback_response: str = Field( | |
| default=( | |
| "I don't have specific information about that in my current knowledge base. " | |
| "For accurate and up-to-date information, please visit the official ACPC Gujarat website: " | |
| "https://acpc.gujarat.gov.in/ or contact the ACPC helpline." | |
| ) | |
| ) | |
| settings = Settings() |