Spaces:
Runtime error
Runtime error
changes to app
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ import uuid
|
|
7 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
8 |
|
9 |
from src.document_retrieval import DocumentRetrieval
|
10 |
-
from utils.visual.env_utils import env_input_fields, initialize_env_variables, are_credentials_set, save_credentials
|
11 |
from utils.parsing.sambaparse import parse_doc_universal # added
|
12 |
from utils.vectordb.vector_db import VectorDb
|
13 |
|
@@ -36,14 +35,13 @@ def process_documents(files, collection_name, document_retrieval, vectorstore, c
|
|
36 |
document_retrieval = DocumentRetrieval()
|
37 |
_, _, text_chunks = parse_doc_universal(doc=files)
|
38 |
print(len(text_chunks))
|
39 |
-
print(text_chunks)
|
40 |
embeddings = document_retrieval.load_embedding_model()
|
41 |
collection_id = str(uuid.uuid4())
|
42 |
collection_name = f"collection_{collection_id}"
|
43 |
vectorstore = document_retrieval.create_vector_store(text_chunks, embeddings, output_db=save_location, collection_name=collection_name)
|
44 |
document_retrieval.init_retriever(vectorstore)
|
45 |
conversation_chain = document_retrieval.get_qa_retrieval_chain()
|
46 |
-
#input_disabled = False
|
47 |
return conversation_chain, vectorstore, document_retrieval, collection_name, "Complete! You can now ask questions."
|
48 |
except Exception as e:
|
49 |
return conversation_chain, vectorstore, document_retrieval, collection_name, f"An error occurred while processing: {str(e)}"
|
@@ -54,9 +52,6 @@ with open(CONFIG_PATH, 'r') as yaml_file:
|
|
54 |
|
55 |
prod_mode = config.get('prod_mode', False)
|
56 |
|
57 |
-
# Load env variables
|
58 |
-
initialize_env_variables(prod_mode)
|
59 |
-
|
60 |
caution_text = """⚠️ Note: depending on the size of your document, this could take several minutes.
|
61 |
"""
|
62 |
|
|
|
7 |
current_dir = os.path.dirname(os.path.abspath(__file__))
|
8 |
|
9 |
from src.document_retrieval import DocumentRetrieval
|
|
|
10 |
from utils.parsing.sambaparse import parse_doc_universal # added
|
11 |
from utils.vectordb.vector_db import VectorDb
|
12 |
|
|
|
35 |
document_retrieval = DocumentRetrieval()
|
36 |
_, _, text_chunks = parse_doc_universal(doc=files)
|
37 |
print(len(text_chunks))
|
38 |
+
print(text_chunks[0])
|
39 |
embeddings = document_retrieval.load_embedding_model()
|
40 |
collection_id = str(uuid.uuid4())
|
41 |
collection_name = f"collection_{collection_id}"
|
42 |
vectorstore = document_retrieval.create_vector_store(text_chunks, embeddings, output_db=save_location, collection_name=collection_name)
|
43 |
document_retrieval.init_retriever(vectorstore)
|
44 |
conversation_chain = document_retrieval.get_qa_retrieval_chain()
|
|
|
45 |
return conversation_chain, vectorstore, document_retrieval, collection_name, "Complete! You can now ask questions."
|
46 |
except Exception as e:
|
47 |
return conversation_chain, vectorstore, document_retrieval, collection_name, f"An error occurred while processing: {str(e)}"
|
|
|
52 |
|
53 |
prod_mode = config.get('prod_mode', False)
|
54 |
|
|
|
|
|
|
|
55 |
caution_text = """⚠️ Note: depending on the size of your document, this could take several minutes.
|
56 |
"""
|
57 |
|