Spaces:
Runtime error
Runtime error
Commit
·
eb99c4b
1
Parent(s):
4283189
Update app.py
Browse files
app.py
CHANGED
@@ -152,7 +152,7 @@ def create_vector_database(loaded_documents):
|
|
152 |
"""
|
153 |
|
154 |
# Split loaded documents into chunks
|
155 |
-
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=40)
|
156 |
chunked_documents = text_splitter.split_documents(loaded_documents)
|
157 |
|
158 |
# Initialize HuggingFace embeddings
|
@@ -229,7 +229,7 @@ def create_chain(llm, prompt, CONDENSE_QUESTION_PROMPT, db):
|
|
229 |
chain_type="stuff",
|
230 |
retriever=db.as_retriever(search_kwargs={"k": 3}),
|
231 |
return_source_documents=True,
|
232 |
-
max_tokens_limit=
|
233 |
combine_docs_chain_kwargs={"prompt": prompt},
|
234 |
condense_question_prompt=CONDENSE_QUESTION_PROMPT,
|
235 |
memory=memory,
|
@@ -314,7 +314,7 @@ def main():
|
|
314 |
# Check if the extension is in FILE_LOADER_MAPPING
|
315 |
if ext in FILE_LOADER_MAPPING:
|
316 |
loader_class, loader_args = FILE_LOADER_MAPPING[ext]
|
317 |
-
st.write(f"loader_class: {loader_class}")
|
318 |
|
319 |
# Save the uploaded file to the temporary directory
|
320 |
file_path = os.path.join(td, uploaded_file.name)
|
@@ -327,7 +327,7 @@ def main():
|
|
327 |
else:
|
328 |
st.warning(f"Unsupported file extension: {ext}")
|
329 |
|
330 |
-
st.write(f"loaded_documents: {loaded_documents}")
|
331 |
st.write("Chat with the Document:")
|
332 |
query = st.text_input("Ask a question:")
|
333 |
|
@@ -339,9 +339,9 @@ def main():
|
|
339 |
prompt = set_custom_prompt()
|
340 |
CONDENSE_QUESTION_PROMPT = set_custom_prompt_condense()
|
341 |
db = create_vector_database(loaded_documents)
|
342 |
-
st.write(f"db: {db}")
|
343 |
response = retrieve_bot_answer(query,loaded_documents)
|
344 |
-
st.write(f"response: {response}")
|
345 |
# Display bot response
|
346 |
st.write("Bot Response:")
|
347 |
st.write(response)
|
|
|
152 |
"""
|
153 |
|
154 |
# Split loaded documents into chunks
|
155 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=40, length_function = len)
|
156 |
chunked_documents = text_splitter.split_documents(loaded_documents)
|
157 |
|
158 |
# Initialize HuggingFace embeddings
|
|
|
229 |
chain_type="stuff",
|
230 |
retriever=db.as_retriever(search_kwargs={"k": 3}),
|
231 |
return_source_documents=True,
|
232 |
+
max_tokens_limit=256,
|
233 |
combine_docs_chain_kwargs={"prompt": prompt},
|
234 |
condense_question_prompt=CONDENSE_QUESTION_PROMPT,
|
235 |
memory=memory,
|
|
|
314 |
# Check if the extension is in FILE_LOADER_MAPPING
|
315 |
if ext in FILE_LOADER_MAPPING:
|
316 |
loader_class, loader_args = FILE_LOADER_MAPPING[ext]
|
317 |
+
# st.write(f"loader_class: {loader_class}")
|
318 |
|
319 |
# Save the uploaded file to the temporary directory
|
320 |
file_path = os.path.join(td, uploaded_file.name)
|
|
|
327 |
else:
|
328 |
st.warning(f"Unsupported file extension: {ext}")
|
329 |
|
330 |
+
# st.write(f"loaded_documents: {loaded_documents}")
|
331 |
st.write("Chat with the Document:")
|
332 |
query = st.text_input("Ask a question:")
|
333 |
|
|
|
339 |
prompt = set_custom_prompt()
|
340 |
CONDENSE_QUESTION_PROMPT = set_custom_prompt_condense()
|
341 |
db = create_vector_database(loaded_documents)
|
342 |
+
# st.write(f"db: {db}")
|
343 |
response = retrieve_bot_answer(query,loaded_documents)
|
344 |
+
# st.write(f"response: {response}")
|
345 |
# Display bot response
|
346 |
st.write("Bot Response:")
|
347 |
st.write(response)
|