farmax commited on
Commit
cd982b5
·
verified ·
1 Parent(s): 6739a2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -38,7 +38,6 @@ class PDFDocument(Document):
38
 
39
  def initialize_database(document, chunk_size, chunk_overlap, progress=gr.Progress()):
40
  logger.info("Initializing database...")
41
- embedding_function = Chroma.from_pretrained("chroma-rt")
42
  documents = []
43
  for file in document:
44
  loader = UnstructuredPDFLoader(file.name)
@@ -48,11 +47,12 @@ def initialize_database(document, chunk_size, chunk_overlap, progress=gr.Progres
48
  pages = splitter.split_document(doc)
49
  for page in pages:
50
  documents.append(PDFDocument(page_content=page.page_content, metadata={"filename": file.name}))
51
- vectorstore = Chroma.create_index(embedding_function, documents)
 
52
  progress.update(0.5)
53
  logger.info("Database initialized successfully.")
54
  return vectorstore, "Initialized"
55
-
56
  def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db, progress=gr.Progress(), language="italian"):
57
  logger.info("Initializing LLM chain...")
58
  llm_name = list_llm[llm_option]
 
38
 
39
  def initialize_database(document, chunk_size, chunk_overlap, progress=gr.Progress()):
40
  logger.info("Initializing database...")
 
41
  documents = []
42
  for file in document:
43
  loader = UnstructuredPDFLoader(file.name)
 
47
  pages = splitter.split_document(doc)
48
  for page in pages:
49
  documents.append(PDFDocument(page_content=page.page_content, metadata={"filename": file.name}))
50
+
51
+ vectorstore = Chroma.from_documents(documents, embedding_function)
52
  progress.update(0.5)
53
  logger.info("Database initialized successfully.")
54
  return vectorstore, "Initialized"
55
+
56
  def initialize_LLM(llm_option, llm_temperature, max_tokens, top_k, vector_db, progress=gr.Progress(), language="italian"):
57
  logger.info("Initializing LLM chain...")
58
  llm_name = list_llm[llm_option]