| """Application configuration management""" |
|
|
| from pydantic_settings import BaseSettings |
| from functools import lru_cache |
| import os |
|
|
|
|
| class Settings(BaseSettings): |
| """Application settings loaded from environment variables""" |
|
|
| |
| environment: str = "development" |
| debug: bool = False |
| log_level: str = "INFO" |
|
|
| |
| groq_api_key: str = "" |
|
|
| |
| database_url: str = "sqlite:///./data/ragapp.db" |
| vector_db_type: str = "chroma" |
| chroma_storage_path: str = "./data/chroma_data" |
|
|
| |
| pinecone_api_key: str = "" |
| pinecone_environment: str = "" |
| weaviate_url: str = "http://localhost:8080" |
| weaviate_api_key: str = "" |
| qdrant_url: str = "http://localhost:6333" |
| qdrant_api_key: str = "" |
|
|
| |
| default_model: str = "llama-3.1-8b-instant" |
| default_embedding_model: str = "all-MiniLM-L6-v2" |
| default_tokenizer: str = "tiktoken" |
| chunk_size: int = 512 |
| chunk_overlap: int = 50 |
| retrieval_top_k: int = 5 |
| generation_temperature: float = 0.7 |
|
|
| |
| secret_key: str = "your-secret-key-change-in-production" |
| jwt_algorithm: str = "HS256" |
| jwt_expiration_hours: int = 24 |
|
|
| |
| frontend_url: str = "http://localhost:3000" |
|
|
| |
| upload_dir: str = "./data/uploads" |
| max_file_size: int = 52428800 |
|
|
| |
| log_file: str = "./logs/ragapp.log" |
|
|
| class Config: |
| env_file = ".env" |
| case_sensitive = False |
|
|
| def __init__(self, **data): |
| super().__init__(**data) |
| os.makedirs(self.upload_dir, exist_ok=True) |
| os.makedirs(self.chroma_storage_path, exist_ok=True) |
| os.makedirs(os.path.dirname(self.log_file), exist_ok=True) |
|
|
|
|
| @lru_cache() |
| def get_settings() -> Settings: |
| """Get cached settings instance""" |
| return Settings() |
|
|