Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -15,10 +15,10 @@ html_content = f"""
|
|
15 |
</style>
|
16 |
<div style='display: flex; flex-direction: column; align-items: flex-start;'>
|
17 |
<div style='display: flex; align-items: center;'>
|
18 |
-
<div style='width: 20px; height:
|
19 |
-
<div style='width: 20px; height:
|
20 |
-
<div style='width: 20px; height:
|
21 |
-
<span style='font-size:
|
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'>
|
@@ -147,35 +147,40 @@ def apply_prophet(df_clean):
|
|
147 |
# Renomear colunas e aplicar filtros
|
148 |
return all_anomalies
|
149 |
|
|
|
|
|
150 |
# Interface para carregar arquivo
|
151 |
uploaded_file = st.file_uploader("Carregue um arquivo CSV ou XLSX", type=['csv', 'xlsx'])
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
st.
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
st.session_state['
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
15 |
</style>
|
16 |
<div style='display: flex; flex-direction: column; align-items: flex-start;'>
|
17 |
<div style='display: flex; align-items: center;'>
|
18 |
+
<div style='width: 20px; height: 5px; background-color: green; margin-right: 0px;'></div>
|
19 |
+
<div style='width: 20px; height: 5px; background-color: red; margin-right: 0px;'></div>
|
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'>
|
|
|
147 |
# Renomear colunas e aplicar filtros
|
148 |
return all_anomalies
|
149 |
|
150 |
+
tab1, tab2 = st.tabs(["Meta Prophet", "Microsoft TAPEX"])
|
151 |
+
|
152 |
# Interface para carregar arquivo
|
153 |
uploaded_file = st.file_uploader("Carregue um arquivo CSV ou XLSX", type=['csv', 'xlsx'])
|
154 |
+
|
155 |
+
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 |
+
with st.spinner('Aplicando modelo de série temporal...'):
|
163 |
+
all_anomalies = apply_prophet(df_clean)
|
164 |
+
st.session_state['all_anomalies'] = all_anomalies
|
165 |
+
|
166 |
+
with tab2:
|
167 |
+
# Interface para perguntas do usuário
|
168 |
+
user_question = st.text_input("Escreva sua questão aqui:", "")
|
169 |
+
if user_question:
|
170 |
+
if 'all_anomalies' in st.session_state and not st.session_state['all_anomalies'].empty:
|
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 |
+
else:
|
175 |
+
st.warning("Ainda não há dados de anomalias para responder a pergunta.")
|
176 |
+
|
177 |
+
# Mostrar histórico de conversa
|
178 |
+
for sender, message in st.session_state['history']:
|
179 |
+
if sender == '👤':
|
180 |
+
st.markdown(f"**👤 {message}**")
|
181 |
+
elif sender == '🤖':
|
182 |
+
st.markdown(f"**🤖 {message}**", unsafe_allow_html=True)
|
183 |
+
|
184 |
+
# Botão para limpar histórico
|
185 |
+
if st.button("Limpar histórico"):
|
186 |
+
st.session_state['history'] = []
|