File size: 2,240 Bytes
653f79c
 
 
 
 
 
 
 
7757db2
 
ee6cd88
c6fb648
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15e9c77
c6fb648
 
 
653f79c
 
 
 
c6fb648
653f79c
c6fb648
 
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# opted for sigleton as opposed to global variable

# Create a singleton object to hold all shared states
# This ensures that only one instance of the Config class is ever created
class Config:
    """ Single model_dict use across the app"""
    def __init__(self):
        self.model_dict = {}
        self.weasyprint_libpath = ""
        self.config_ini = "utils\\config.ini"
        self.pdf_files_count = 0
        self.output_dir = ""
        
        # File types
        self.file_types_list  = []
        self.file_types_tuple = (".pdf", ".html", ".docx", ".doc")

        # all other variables shared across the app 
        #self.pdf_files: list[str] = []
        #self.pdf_files_count: int = 0
        self.provider: str = ""
        self.model_id: str = ""
        #base_url: str
        self.hf_provider: str = ""
        self.endpoint: str = ""
        self.backend_choice: str = ""
        self.system_message: str = ""
        self.max_tokens: int = 8192
        self.temperature: float = 1.0
        self.top_p: float = 1.0
        self.stream: bool = False
        self.api_token: str = ""
        self.openai_base_url: str = "https://router.huggingface.co/v1"
        self.openai_image_format: str = "webp"
        self.max_workers: int = 1
        self.max_retries: int = 2
        self.debug: bool = False
        #output_format: str = "markdown",
        self.output_format: str = "markdown"
        self.output_dir_string: str = "output_dir_default"
        self.use_llm: bool = False
        self.force_ocr: bool = True             #False,
        self.strip_existing_ocr: bool = False    #bool = False,
        self.disable_ocr_math: bool = None      #bool = False,
        self.page_range: str = None
        #self.weasyprint_dll_directories: str = None,
        self.tz_hours: str = None
        self.pooling: str = "no_pooling",  #bool = True  #False
        #oauth_token: gr.OAuthToken | None=None,
        #progress: gr.Progress = gr.Progress(track_tqdm=True),  #Progress tracker to keep tab on pool queue executor


# Create a single, shared instance of the Config class
# Other modules will import and use this instance.
config_load_models = Config()
config_load = Config()

#if __name__ == "__main__":