default true
Browse files
app.py
CHANGED
@@ -67,10 +67,7 @@ with st.sidebar:
|
|
67 |
)
|
68 |
|
69 |
# Use dictionary
|
70 |
-
use_dict_format = st.checkbox("Use dictionary format.")
|
71 |
-
|
72 |
-
# Submit button
|
73 |
-
submit_it = st.sidebar.button("Submit", type="primary")
|
74 |
|
75 |
# Clear button
|
76 |
clear_button = st.sidebar.button("Clear Conversation", key="clear")
|
@@ -105,38 +102,36 @@ if uploaded_files is None:
|
|
105 |
# Display a message prompting the user to upload files
|
106 |
st.info("Upload files to analyze")
|
107 |
|
108 |
-
|
109 |
elif uploaded_files:
|
110 |
-
|
111 |
-
|
112 |
-
textify_output = read_and_textify(uploaded_files)
|
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 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
|
|
67 |
)
|
68 |
|
69 |
# Use dictionary
|
70 |
+
use_dict_format = st.checkbox("Use dictionary format.", value=True)
|
|
|
|
|
|
|
71 |
|
72 |
# Clear button
|
73 |
clear_button = st.sidebar.button("Clear Conversation", key="clear")
|
|
|
102 |
# Display a message prompting the user to upload files
|
103 |
st.info("Upload files to analyze")
|
104 |
|
|
|
105 |
elif uploaded_files:
|
106 |
+
# Process the uploaded files to extract text and source information
|
107 |
+
textify_output = read_and_textify(uploaded_files)
|
|
|
108 |
|
109 |
+
# Separate the output into documents (text) and their corresponding sources
|
110 |
+
documents, sources = textify_output
|
111 |
|
112 |
+
# Call the function
|
113 |
+
query_database = list_to_nums(documents)
|
114 |
|
115 |
+
# Create reference table
|
116 |
+
refs_tab = query_search(
|
117 |
+
"pful for understanding federal income", documents, query_database, sources
|
118 |
+
)
|
119 |
+
refs_tab.head(math.ceil(top_n))
|
120 |
+
|
121 |
+
# React to user input
|
122 |
+
if prompt := st.chat_input("What is up?"):
|
123 |
+
# Display user message in chat message container
|
124 |
+
st.chat_message("user").markdown(prompt)
|
125 |
+
# Add user message to chat history
|
126 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
127 |
+
|
128 |
+
result = refs_tab
|
129 |
+
|
130 |
+
# Display assistant response in chat message container
|
131 |
+
with st.chat_message("assistant"):
|
132 |
+
if not use_dict_format:
|
133 |
+
st.table(result)
|
134 |
+
else:
|
135 |
+
st.write(result.to_json())
|
136 |
+
# Add assistant response to chat history
|
137 |
+
st.session_state.messages.append({"role": "assistant", "content": result})
|