File size: 1,396 Bytes
698965e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from src.config.configs import *
from functools import lru_cache
from typing import Any
import config as c

class AppConfig:
    # ===================== INITIALIZE YOUR SUBCONFIGS HERE =====================
    
    convstate:  ConversationStateConfig = ConversationStateConfig()
    processing: ProcessingConfig        = ProcessingConfig()
    weaviate:   WeaviateConfig          = WeaviateConfig()
    scraping:   ScrapingConfig          = ScrapingConfig()
    chain:      ChainConfig             = ChainConfig()
    cache:      CacheConfig             = CacheConfig()
    paths:      PathsConfig             = PathsConfig()
    dbapp:      DatabaseAppConfig       = DatabaseAppConfig()
    llm:        LLMProviderConfig       = LLMProviderConfig()
    
    # ===========================================================================

    def get(self, key: str, default: Any = None) -> Any:
        """
        Retrieves an extra parameter from config.py by name.
        
        Raises: 
            AttributeError if not found and no default provided.
        """
        try:
            return getattr(c, key)
        except AttributeError:
            if default is not None:
                return default
            raise AttributeError(f"Config parameter '{key}' is not defined!")

@lru_cache(maxsize=1)
def get_config() -> AppConfig:
    return AppConfig()

config = get_config()