File size: 1,463 Bytes
9ff01ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9a9d439
 
9ff01ff
9a9d439
9ff01ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import pandas as pd
import os
from langchain.llms import OpenAI
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

#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")
    retriever = Retriever(client_db, None, "illumio_database")
except:
    print("Database is empty")
    doc = Doc(path=content_en_path_real)
    retriever = Retriever(client_db,doc.container,"illumio_database")

llm_model = OpenAI(temperature=0)
llm = LlmAgent(llm_model)

chat = Chatbot(llm_agent=llm, retriever=retriever)

ilumio_qna = view.run(ctrl=chat, config=view_config)

ilumio_qna.queue().launch()