Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -61,13 +61,18 @@ else:
|
|
61 |
with st.spinner():
|
62 |
if st.button('Generate Graph'):
|
63 |
try:
|
|
|
|
|
|
|
|
|
|
|
64 |
# Use TAPAS model to process the question
|
65 |
result = tqa(table=df, query=question)
|
66 |
|
67 |
-
# Check if TAPAS is returning
|
68 |
answer = result['answer']
|
69 |
st.write(f"TAPAS Answer: {answer}")
|
70 |
-
|
71 |
# Determine if the question relates to graph generation
|
72 |
if 'between' in question.lower() and 'and' in question.lower():
|
73 |
# This is a request for a scatter plot (two columns)
|
@@ -81,7 +86,7 @@ else:
|
|
81 |
st.warning("Columns not found in the dataset.")
|
82 |
elif 'column' in question.lower():
|
83 |
# This is a request for a line graph (single column)
|
84 |
-
column = question.split('of')[-1].strip()
|
85 |
if column in df.columns:
|
86 |
fig = px.line(df, x=df.index, y=column, title=f"Graph of column '{column}'")
|
87 |
st.plotly_chart(fig, use_container_width=True)
|
|
|
61 |
with st.spinner():
|
62 |
if st.button('Generate Graph'):
|
63 |
try:
|
64 |
+
# Ensure the question is a string
|
65 |
+
if not isinstance(question, str):
|
66 |
+
st.error("The question input is not a valid string.")
|
67 |
+
return
|
68 |
+
|
69 |
# Use TAPAS model to process the question
|
70 |
result = tqa(table=df, query=question)
|
71 |
|
72 |
+
# Check if TAPAS is returning the expected answer
|
73 |
answer = result['answer']
|
74 |
st.write(f"TAPAS Answer: {answer}")
|
75 |
+
|
76 |
# Determine if the question relates to graph generation
|
77 |
if 'between' in question.lower() and 'and' in question.lower():
|
78 |
# This is a request for a scatter plot (two columns)
|
|
|
86 |
st.warning("Columns not found in the dataset.")
|
87 |
elif 'column' in question.lower():
|
88 |
# This is a request for a line graph (single column)
|
89 |
+
column = question.split('of')[-1].strip() # Handle 'of' keyword
|
90 |
if column in df.columns:
|
91 |
fig = px.line(df, x=df.index, y=column, title=f"Graph of column '{column}'")
|
92 |
st.plotly_chart(fig, use_container_width=True)
|