Spaces:
Sleeping
Sleeping
Update functions.py
Browse files- functions.py +17 -3
functions.py
CHANGED
@@ -50,7 +50,22 @@ async def handle_userinput(user_question, custom_graph):
|
|
50 |
st.subheader("Your documents")
|
51 |
with st.spinner("Processing"):
|
52 |
for doc in docs:
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
# Check if a response (generation) was produced by the graph
|
56 |
if 'generation' in state_dict and state_dict['generation']:
|
@@ -66,8 +81,7 @@ async def handle_userinput(user_question, custom_graph):
|
|
66 |
except Exception as e:
|
67 |
# Display an error message in case of failure
|
68 |
st.chat_message("assistant").write("An error occurred: Try to change the question.")
|
69 |
-
st.chat_message("assistant").write(e)
|
70 |
-
|
71 |
|
72 |
|
73 |
def create_retriever_from_chroma(vectorstore_path="./docs/chroma/", search_type='mmr', k=7, chunk_size=550, chunk_overlap=40):
|
|
|
50 |
st.subheader("Your documents")
|
51 |
with st.spinner("Processing"):
|
52 |
for doc in docs:
|
53 |
+
# Extract document content
|
54 |
+
content = doc.page_content # Assuming the document has a `page_content` attribute
|
55 |
+
|
56 |
+
# Extract document metadata if available
|
57 |
+
metadata = doc.metadata if hasattr(doc, 'metadata') else {}
|
58 |
+
|
59 |
+
# Display content and metadata
|
60 |
+
st.write(f"Document: {content}")
|
61 |
+
|
62 |
+
# Display metadata (assuming it's a dictionary)
|
63 |
+
if metadata:
|
64 |
+
st.write("Metadata:")
|
65 |
+
for key, value in metadata.items():
|
66 |
+
st.write(f"- {key}: {value}")
|
67 |
+
else:
|
68 |
+
st.write("No metadata available.")
|
69 |
|
70 |
# Check if a response (generation) was produced by the graph
|
71 |
if 'generation' in state_dict and state_dict['generation']:
|
|
|
81 |
except Exception as e:
|
82 |
# Display an error message in case of failure
|
83 |
st.chat_message("assistant").write("An error occurred: Try to change the question.")
|
84 |
+
st.chat_message("assistant").write(e)
|
|
|
85 |
|
86 |
|
87 |
def create_retriever_from_chroma(vectorstore_path="./docs/chroma/", search_type='mmr', k=7, chunk_size=550, chunk_overlap=40):
|