Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -47,7 +47,7 @@ def load_doc(list_file_path, chunk_size, chunk_overlap):
|
|
| 47 |
|
| 48 |
# Create vector database
|
| 49 |
def create_db(splits, collection_name):
|
| 50 |
-
embedding = HuggingFaceEmbeddings()
|
| 51 |
new_client = chromadb.EphemeralClient()
|
| 52 |
vectordb = Chroma.from_documents(
|
| 53 |
documents=splits,
|
|
@@ -61,7 +61,7 @@ def create_db(splits, collection_name):
|
|
| 61 |
|
| 62 |
# Load vector database
|
| 63 |
def load_db():
|
| 64 |
-
embedding = HuggingFaceEmbeddings()
|
| 65 |
vectordb = Chroma(
|
| 66 |
# persist_directory=default_persist_directory,
|
| 67 |
embedding_function=embedding)
|
|
@@ -132,8 +132,8 @@ def initialize_database(list_file_obj, chunk_size, chunk_overlap, progress=gr.Pr
|
|
| 132 |
#file_path = file_obj.name
|
| 133 |
list_file_path = [x.name for x in list_file_obj if x is not None]
|
| 134 |
collection_name = Path(list_file_path[0]).stem
|
| 135 |
-
|
| 136 |
-
|
| 137 |
progress(0.25, desc="Loading document...")
|
| 138 |
# Load document and create splits
|
| 139 |
doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
|
|
@@ -174,8 +174,7 @@ def conversation(qa_chain, message, history):
|
|
| 174 |
# Langchain sources are zero-based
|
| 175 |
response_source1_page = response_sources[0].metadata["page"] + 1
|
| 176 |
response_source2_page = response_sources[1].metadata["page"] + 1
|
| 177 |
-
|
| 178 |
-
# print('DB source', response_sources)
|
| 179 |
|
| 180 |
# Append user message and response to chat history
|
| 181 |
new_history = history + [(message, response_answer)]
|
|
|
|
| 47 |
|
| 48 |
# Create vector database
|
| 49 |
def create_db(splits, collection_name):
|
| 50 |
+
embedding = HuggingFaceEmbeddings(model_name="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
|
| 51 |
new_client = chromadb.EphemeralClient()
|
| 52 |
vectordb = Chroma.from_documents(
|
| 53 |
documents=splits,
|
|
|
|
| 61 |
|
| 62 |
# Load vector database
|
| 63 |
def load_db():
|
| 64 |
+
embedding = HuggingFaceEmbeddings(model_name="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
|
| 65 |
vectordb = Chroma(
|
| 66 |
# persist_directory=default_persist_directory,
|
| 67 |
embedding_function=embedding)
|
|
|
|
| 132 |
#file_path = file_obj.name
|
| 133 |
list_file_path = [x.name for x in list_file_obj if x is not None]
|
| 134 |
collection_name = Path(list_file_path[0]).stem
|
| 135 |
+
print('list_file_path: ', list_file_path)
|
| 136 |
+
print('Collection name: ', collection_name)
|
| 137 |
progress(0.25, desc="Loading document...")
|
| 138 |
# Load document and create splits
|
| 139 |
doc_splits = load_doc(list_file_path, chunk_size, chunk_overlap)
|
|
|
|
| 174 |
# Langchain sources are zero-based
|
| 175 |
response_source1_page = response_sources[0].metadata["page"] + 1
|
| 176 |
response_source2_page = response_sources[1].metadata["page"] + 1
|
| 177 |
+
print ('Response: ', response)
|
|
|
|
| 178 |
|
| 179 |
# Append user message and response to chat history
|
| 180 |
new_history = history + [(message, response_answer)]
|