from db import load_sqlite_engine, get_prompt_tinydb, get_all_dataset
from tools import scan_docs_directory

_prompt_store = None
_sql_engine = None
_datasets = None
_model = None
_tokenizer = None
_workdir = None
def init_global_var(workdir="workdir"):
    global _prompt_store, _sql_engine, _datasets, _workdir
    _prompt_store = get_prompt_tinydb(workdir)
    _sql_engine = load_sqlite_engine(workdir)
    _datasets = get_all_dataset(workdir)
    _workdir = workdir

def get_workdir():
    return _workdir

def get_prompt_store():
    return _prompt_store

def set_prompt_store(new_prompt_store):
    global _prompt_store
    _prompt_store = new_prompt_store

def get_sql_engine():
    return _sql_engine

def set_sql_engine(new_sql_engine):
    global _sql_engine
    _sql_engine = new_sql_engine

def get_docs():
    global _workdir
    return scan_docs_directory(_workdir)
def get_datasets():
    return _datasets

def get_model():
    return _model

def set_model(new_model):
    global _model
    _model = new_model

def get_tokenizer():
    return _tokenizer

def set_tokenizer(new_tokenizer):
    global _tokenizer
    _tokenizer = new_tokenizer