import os print("upgrade pip") os.system("pip install --upgrade pip") import chromadb import torch from config import * from src.tools.reader import get_pdf_title_styles from src.tools.llm import LlmAgent import src.view.view as view from src.tools.pretty_print import pretty_print_container_structure, pretty_printer_paragraphs from src.model.container import Container from src.control.control import Chatbot from src.tools.retriever import Retriever from src.model.doc import Doc from chromadb.config import Settings os.environ["TOKENIZERS_PARALLELISM"] = "true" if not "TOKEN_HF" in os.environ: from config_key import TOKEN_HF os.environ['TOKEN_HF'] = TOKEN_HF # start_time = time.time() # doc = Doc(path=content_en_path_real) # print("--- %s seconds ---" % (time.time() - start_time)) # check if the database is empty # pdf_manager(pdf_path=content_en_path_real) # pretty_printer_paragraphs(doc.container.paragraphs) # pretty_print_container_structure(doc.container) if not os.path.exists("database/"): os.makedirs("database/") client_db = chromadb.Client() try: client_db.get_collection(name="illumio_database") llm = LlmAgent(model="TheBloke/Llama-2-7B-chat-GPTQ",token=os.environ["TOKEN_HF"]) retriever = Retriever(client_db, None, "illumio_database", llmagent=llm) except: print("Database is empty") doc = Doc(path=content_en_path_real) llm = LlmAgent(model="TheBloke/Llama-2-7B-chat-GPTQ",token=os.environ["TOKEN_HF"]) retriever = Retriever(client_db,doc.container,"illumio_database",llmagent=llm) chat = Chatbot(llm_agent=llm, retriever=retriever) ilumio_qna = view.run(ctrl=chat, config=view_config) ilumio_qna.queue().launch()