Spaces:
Runtime error
Runtime error
Commit
·
124247d
1
Parent(s):
23e04e2
added default index
Browse files
app.py
CHANGED
@@ -106,38 +106,40 @@ with st.expander("Upload csv file"):
|
|
106 |
if uploaded_file is not None:
|
107 |
df = load_data(uploaded_file)
|
108 |
|
109 |
-
#
|
110 |
-
user_idx = st.text_input('Enter index')
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
|
106 |
if uploaded_file is not None:
|
107 |
df = load_data(uploaded_file)
|
108 |
|
109 |
+
# Ask user for index to try out
|
110 |
+
user_idx = st.text_input(f'Enter index (max {df.shape[0] - 1}', "0")
|
111 |
+
|
112 |
+
# Only run rest of script if user provides index
|
113 |
+
if user_idx is not None:
|
114 |
+
first_example = df['review'][int(user_idx)]
|
115 |
+
question = "How was the recipe improved?"
|
116 |
+
if postprocessing == "no postprocessing":
|
117 |
+
resp = question_answer(question=question,
|
118 |
+
context=first_example,
|
119 |
+
top_k=5)
|
120 |
+
elif postprocessing == "remove substrings":
|
121 |
+
resp = question_answer(question=question,
|
122 |
+
context=first_example,
|
123 |
+
top_k=5)
|
124 |
+
resp = remove_substring(resp)
|
125 |
+
elif postprocessing == "iteration":
|
126 |
+
resp = remove_substring_iter(question_answer,
|
127 |
+
question,
|
128 |
+
first_example)
|
129 |
+
|
130 |
+
# Present results
|
131 |
+
st.markdown(f"""
|
132 |
+
# Results
|
133 |
+
|
134 |
+
The review provided was:
|
135 |
+
|
136 |
+
{first_example}
|
137 |
+
|
138 |
+
The question asked was:
|
139 |
+
|
140 |
+
{question}
|
141 |
+
|
142 |
+
The answers were:
|
143 |
+
|
144 |
+
{resp}
|
145 |
+
""")
|