Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,14 +15,21 @@ import datetime
|
|
| 15 |
#print(df.head())
|
| 16 |
|
| 17 |
df = pd.read_csv("anomalies.csv",quotechar='"',dtype={col: str for col in pd.read_csv('anomalies.csv', nrows=1)})
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Function to generate a response using the TAPEX model
|
| 20 |
def response(user_question, df):
|
| 21 |
a = datetime.datetime.now()
|
| 22 |
|
| 23 |
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
answer = tqa(table=df, query=user_question)['answer']
|
| 25 |
-
|
| 26 |
query_result = {
|
| 27 |
"Resposta": answer
|
| 28 |
}
|
|
|
|
| 15 |
#print(df.head())
|
| 16 |
|
| 17 |
df = pd.read_csv("anomalies.csv",quotechar='"',dtype={col: str for col in pd.read_csv('anomalies.csv', nrows=1)})
|
| 18 |
+
df = df.fillna('').astype(str)
|
| 19 |
+
|
| 20 |
|
| 21 |
# Function to generate a response using the TAPEX model
|
| 22 |
def response(user_question, df):
|
| 23 |
a = datetime.datetime.now()
|
| 24 |
|
| 25 |
tqa = pipeline(task="table-question-answering", model="google/tapas-large-finetuned-wtq")
|
| 26 |
+
|
| 27 |
+
print("DataFrame shape:", df.shape)
|
| 28 |
+
print("DataFrame head:\n", df.head())
|
| 29 |
+
print("User question:", user_question)
|
| 30 |
+
|
| 31 |
answer = tqa(table=df, query=user_question)['answer']
|
| 32 |
+
|
| 33 |
query_result = {
|
| 34 |
"Resposta": answer
|
| 35 |
}
|