Spaces:
Running
Running
fschwartzer
commited on
Commit
•
edfa911
1
Parent(s):
b375123
Update app.py
Browse files
app.py
CHANGED
@@ -20,10 +20,6 @@ html_content = f"""
|
|
20 |
<div style='width: 20px; height: 5px; background-color: yellow; margin-right: 18px;'></div>
|
21 |
<span style='font-size: 38px; font-weight: normal; font-family: "Kanit", sans-serif;'>NOSTRADAMUS</span>
|
22 |
</div>
|
23 |
-
<div style='text-align: left; width: 100%;'>
|
24 |
-
<span style='font-size: 24px; font-weight: normal; color: #333; font-family: "Kanit", sans-serif'>
|
25 |
-
Meta Prophet + Microsoft TAPEX</span>
|
26 |
-
</div>
|
27 |
</div>
|
28 |
"""
|
29 |
|
@@ -156,31 +152,35 @@ with tab1:
|
|
156 |
if uploaded_file:
|
157 |
df = load_data(uploaded_file)
|
158 |
df_clean = preprocess_data(df)
|
|
|
159 |
if df_clean.empty:
|
160 |
st.warning("Não há dados válidos para processar.")
|
161 |
else:
|
162 |
-
|
163 |
-
|
164 |
-
st.
|
|
|
|
|
165 |
|
166 |
with tab2:
|
167 |
-
#
|
168 |
-
|
169 |
-
|
170 |
-
|
|
|
171 |
bot_response = response(user_question, st.session_state['all_anomalies'])
|
172 |
st.session_state['history'].append(('👤', user_question))
|
173 |
st.session_state['history'].append(('🤖', bot_response))
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
st.
|
|
|
20 |
<div style='width: 20px; height: 5px; background-color: yellow; margin-right: 18px;'></div>
|
21 |
<span style='font-size: 38px; font-weight: normal; font-family: "Kanit", sans-serif;'>NOSTRADAMUS</span>
|
22 |
</div>
|
|
|
|
|
|
|
|
|
23 |
</div>
|
24 |
"""
|
25 |
|
|
|
152 |
if uploaded_file:
|
153 |
df = load_data(uploaded_file)
|
154 |
df_clean = preprocess_data(df)
|
155 |
+
|
156 |
if df_clean.empty:
|
157 |
st.warning("Não há dados válidos para processar.")
|
158 |
else:
|
159 |
+
# Check if 'all_anomalies' is already in session state to avoid re-running Prophet
|
160 |
+
if 'all_anomalies' not in st.session_state:
|
161 |
+
with st.spinner('Aplicando modelo de série temporal...'):
|
162 |
+
all_anomalies = apply_prophet(df_clean)
|
163 |
+
st.session_state['all_anomalies'] = all_anomalies
|
164 |
|
165 |
with tab2:
|
166 |
+
# Ensure 'all_anomalies' exists in session state before allowing user interaction
|
167 |
+
if 'all_anomalies' in st.session_state and not st.session_state['all_anomalies'].empty:
|
168 |
+
# Interface para perguntas do usuário
|
169 |
+
user_question = st.text_input("Escreva sua questão aqui:", "")
|
170 |
+
if user_question:
|
171 |
bot_response = response(user_question, st.session_state['all_anomalies'])
|
172 |
st.session_state['history'].append(('👤', user_question))
|
173 |
st.session_state['history'].append(('🤖', bot_response))
|
174 |
+
|
175 |
+
# Mostrar histórico de conversa
|
176 |
+
for sender, message in st.session_state['history']:
|
177 |
+
if sender == '👤':
|
178 |
+
st.markdown(f"**👤 {message}**")
|
179 |
+
elif sender == '🤖':
|
180 |
+
st.markdown(f"**🤖 {message}**", unsafe_allow_html=True)
|
181 |
+
|
182 |
+
# Botão para limpar histórico
|
183 |
+
if st.button("Limpar histórico"):
|
184 |
+
st.session_state['history'] = []
|
185 |
+
else:
|
186 |
+
st.warning("Por favor, processe os dados no Meta Prophet primeiro.")
|