Spaces:
Running
Running
fschwartzer
commited on
Commit
•
9e11403
1
Parent(s):
86f6c04
Update app.py
Browse files
app.py
CHANGED
@@ -3,29 +3,15 @@ import pandas as pd
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
# Load the anomalies data and convert all cells to strings
|
6 |
-
|
7 |
-
df = pd.
|
8 |
df.fillna("", inplace=True)
|
9 |
print(df.head())
|
10 |
|
11 |
def response(user_question):
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
# Inicializa o pipeline para table-question-answering
|
16 |
-
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
17 |
-
|
18 |
-
# Obtém a resposta do modelo
|
19 |
-
resposta = tqa(table=df, query=user_question)
|
20 |
-
|
21 |
-
# Verifica se alguma célula foi retornada
|
22 |
-
if 'cells' not in resposta or len(resposta['cells']) == 0:
|
23 |
-
raise IndexError("Nenhuma célula foi retornada pelo modelo.")
|
24 |
-
|
25 |
-
# Obtém a primeira célula da resposta
|
26 |
-
final_response = resposta['cells'][0]
|
27 |
-
|
28 |
-
return final_response
|
29 |
|
30 |
# Streamlit interface
|
31 |
st.markdown("""
|
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
# Load the anomalies data and convert all cells to strings
|
6 |
+
df = pd.read_csv('anomalies.csv', sep=',', decimal='.')
|
7 |
+
df['ds'] = pd.to_datetime(df['ds'], format='%Y-%m-%d')
|
8 |
df.fillna("", inplace=True)
|
9 |
print(df.head())
|
10 |
|
11 |
def response(user_question):
|
12 |
+
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
13 |
+
resposta = tqa(table=df, query=user_question)['cells'][0]
|
14 |
+
return print(resposta)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Streamlit interface
|
17 |
st.markdown("""
|