app updated
Browse files
app.py
CHANGED
@@ -103,35 +103,36 @@ if uploaded_files is None:
|
|
103 |
st.info("Upload files to analyze")
|
104 |
|
105 |
elif uploaded_files:
|
106 |
-
|
107 |
-
|
|
|
108 |
|
109 |
-
|
110 |
-
|
111 |
|
112 |
-
|
113 |
-
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
|
|
103 |
st.info("Upload files to analyze")
|
104 |
|
105 |
elif uploaded_files:
|
106 |
+
with st.spinner("Wait for it... 🤔"):
|
107 |
+
# Process the uploaded files to extract text and source information
|
108 |
+
textify_output = read_and_textify(uploaded_files)
|
109 |
|
110 |
+
# Separate the output into documents (text) and their corresponding sources
|
111 |
+
documents, sources = textify_output
|
112 |
|
113 |
+
# Call the function
|
114 |
+
query_database = list_to_nums(documents)
|
115 |
|
116 |
+
# Create reference table
|
117 |
+
refs_tab = query_search(
|
118 |
+
"pful for understanding federal income", documents, query_database, sources
|
119 |
+
)
|
120 |
+
refs_tab.head(math.ceil(top_n))
|
121 |
+
|
122 |
+
# React to user input
|
123 |
+
if prompt := st.chat_input("What is up?"):
|
124 |
+
# Display user message in chat message container
|
125 |
+
st.chat_message("user").markdown(prompt)
|
126 |
+
# Add user message to chat history
|
127 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
128 |
+
|
129 |
+
result = refs_tab
|
130 |
+
|
131 |
+
# Display assistant response in chat message container
|
132 |
+
with st.chat_message("assistant"):
|
133 |
+
if not use_dict_format:
|
134 |
+
st.table(result)
|
135 |
+
else:
|
136 |
+
st.write(result.to_json())
|
137 |
+
# Add assistant response to chat history
|
138 |
+
st.session_state.messages.append({"role": "assistant", "content": result})
|