Update app.py
Browse files
app.py
CHANGED
@@ -151,17 +151,19 @@ if "logs" not in st.session_state:
|
|
151 |
|
152 |
with col1:
|
153 |
if st.button("Submit"):
|
154 |
-
if
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
165 |
with col2:
|
166 |
st.header("Output")
|
167 |
if "graph.png" in os.listdir():
|
@@ -171,4 +173,4 @@ with col2:
|
|
171 |
st.write("No plot generated yet.")
|
172 |
|
173 |
st.header("Live Logs")
|
174 |
-
st.text_area("Logs", value=st.session_state.logs, height=400)
|
|
|
151 |
|
152 |
with col1:
|
153 |
if st.button("Submit"):
|
154 |
+
if not query:
|
155 |
+
st.error("Please enter a query.")
|
156 |
+
else:
|
157 |
+
if "graph.png" in os.listdir():
|
158 |
+
os.remove("graph.png")
|
159 |
+
st.session_state.logs = ""
|
160 |
+
with st.spinner("Generating response..."):
|
161 |
+
bot.query(query)
|
162 |
+
answer_match = re.search(r"Answer:", st.session_state.logs)
|
163 |
+
if answer_match:
|
164 |
+
answer_end_index = answer_match.end()
|
165 |
+
subsequent_text = st.session_state.logs[answer_end_index:].strip()
|
166 |
+
st.success(subsequent_text)
|
167 |
with col2:
|
168 |
st.header("Output")
|
169 |
if "graph.png" in os.listdir():
|
|
|
173 |
st.write("No plot generated yet.")
|
174 |
|
175 |
st.header("Live Logs")
|
176 |
+
st.text_area("Logs", value=st.session_state.logs, height=400, disabled=True)
|