fschwartzer commited on
Commit
b375123
·
verified ·
1 Parent(s): 138e488

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -34
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: 4px; background-color: green; margin-right: 0px;'></div>
19
- <div style='width: 20px; height: 4px; background-color: red; margin-right: 0px;'></div>
20
- <div style='width: 20px; height: 4px; background-color: yellow; margin-right: 20px;'></div>
21
- <span style='font-size: 40px; 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,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
- if uploaded_file:
153
- df = load_data(uploaded_file)
154
- df_clean = preprocess_data(df)
155
- if df_clean.empty:
156
- st.warning("Não dados válidos para processar.")
157
- else:
158
- with st.spinner('Aplicando modelo de série temporal...'):
159
- all_anomalies = apply_prophet(df_clean)
160
- st.session_state['all_anomalies'] = all_anomalies
161
-
162
- # Interface para perguntas do usuário
163
- user_question = st.text_input("Escreva sua questão aqui:", "")
164
- if user_question:
165
- if 'all_anomalies' in st.session_state and not st.session_state['all_anomalies'].empty:
166
- bot_response = response(user_question, st.session_state['all_anomalies'])
167
- st.session_state['history'].append(('👤', user_question))
168
- st.session_state['history'].append(('🤖', bot_response))
169
- else:
170
- st.warning("Ainda não há dados de anomalias para responder a pergunta.")
171
-
172
- # Mostrar histórico de conversa
173
- for sender, message in st.session_state['history']:
174
- if sender == '👤':
175
- st.markdown(f"**👤 {message}**")
176
- elif sender == '🤖':
177
- st.markdown(f"**🤖 {message}**", unsafe_allow_html=True)
178
-
179
- # Botão para limpar histórico
180
- if st.button("Limpar histórico"):
181
- st.session_state['history'] = []
 
 
 
 
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 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 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'] = []