File size: 1,684 Bytes
2e3ba97
 
08dd264
2e3ba97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
968b3e8
 
 
2e3ba97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pandas as pd
import os
os.system("pip install --upgrade pip")
import chromadb

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 src.tools.test_read import pdf_manager

os.environ["TOKENIZERS_PARALLELISM"] = "true"

# if not "OPENAI_API_KEY" in os.environ:
#     from config_key import OPENAI_API_KEY
#     os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY

# 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.PersistentClient(path="database/")

try: 
    client_db.get_collection(name="illumio_database")
    llm = LlmAgent(model="TheBloke/Llama-2-7b-Chat-GPTQ")
    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")
    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()