Spaces:
Runtime error
Runtime error
Timothyxxx
commited on
Commit
·
b44c042
1
Parent(s):
89029fd
Fix typos
Browse files
app.py
CHANGED
|
@@ -184,12 +184,12 @@ st.dataframe(df)
|
|
| 184 |
with col1:
|
| 185 |
selected_language = st.selectbox(
|
| 186 |
"Select a programming language",
|
| 187 |
-
("Binder
|
| 188 |
)
|
| 189 |
-
if selected_language == 'Binder
|
| 190 |
args.prompt_file = 'templates/prompts/prompt_wikitq_v3.txt'
|
| 191 |
args.generate_type = 'nsql'
|
| 192 |
-
elif selected_language == 'Binder
|
| 193 |
args.prompt_file = 'templates/prompts/prompt_wikitq_python_simplified_v4.txt'
|
| 194 |
args.generate_type = 'npython'
|
| 195 |
else:
|
|
@@ -216,13 +216,13 @@ with st.spinner("Generating Binder program to solve the question...will be finis
|
|
| 216 |
|
| 217 |
# Do execution
|
| 218 |
st.subheader("Binder program")
|
| 219 |
-
if selected_language == 'Binder
|
| 220 |
st.markdown('```sql\n' + binder_program + '\n```')
|
| 221 |
# st.markdown('```' + binder_program + '```')
|
| 222 |
# with st.container():
|
| 223 |
# st.write(binder_program)
|
| 224 |
executor = NSQLExecutor(args, keys=keys)
|
| 225 |
-
elif selected_language == 'Binder
|
| 226 |
st.code(binder_program, language='python')
|
| 227 |
executor = NPythonExecutor(args, keys=keys)
|
| 228 |
db = db.get_table_df()
|
|
@@ -233,7 +233,7 @@ try:
|
|
| 233 |
os.makedirs('tmp_for_vis/', exist_ok=True)
|
| 234 |
with st.spinner("Executing... will be finished in 30s, please refresh the page if not"):
|
| 235 |
exec_answer = executor.nsql_exec(stamp, binder_program, db)
|
| 236 |
-
if selected_language == 'Binder
|
| 237 |
with open("tmp_for_vis/{}_tmp_for_vis_steps.txt".format(stamp), "r") as f:
|
| 238 |
steps = json.load(f)
|
| 239 |
for i, step in enumerate(steps):
|
|
@@ -258,7 +258,7 @@ try:
|
|
| 258 |
st.markdown('$\\rightarrow$')
|
| 259 |
if i == len(steps) - 1:
|
| 260 |
# The final step
|
| 261 |
-
st.markdown("{} Interpreter".format(selected_language.replace("Binder
|
| 262 |
else:
|
| 263 |
st.markdown("GPT3 Codex")
|
| 264 |
with st.spinner('...'):
|
|
@@ -280,7 +280,7 @@ try:
|
|
| 280 |
st.markdown(result_in_this_step)
|
| 281 |
with st.spinner('...'):
|
| 282 |
time.sleep(1)
|
| 283 |
-
elif selected_language == 'Binder
|
| 284 |
pass
|
| 285 |
if isinstance(exec_answer, list) and len(exec_answer) == 1:
|
| 286 |
exec_answer = exec_answer[0]
|
|
|
|
| 184 |
with col1:
|
| 185 |
selected_language = st.selectbox(
|
| 186 |
"Select a programming language",
|
| 187 |
+
("Binder-SQL", "Binder-Python"),
|
| 188 |
)
|
| 189 |
+
if selected_language == 'Binder-SQL':
|
| 190 |
args.prompt_file = 'templates/prompts/prompt_wikitq_v3.txt'
|
| 191 |
args.generate_type = 'nsql'
|
| 192 |
+
elif selected_language == 'Binder-Python':
|
| 193 |
args.prompt_file = 'templates/prompts/prompt_wikitq_python_simplified_v4.txt'
|
| 194 |
args.generate_type = 'npython'
|
| 195 |
else:
|
|
|
|
| 216 |
|
| 217 |
# Do execution
|
| 218 |
st.subheader("Binder program")
|
| 219 |
+
if selected_language == 'Binder-SQL':
|
| 220 |
st.markdown('```sql\n' + binder_program + '\n```')
|
| 221 |
# st.markdown('```' + binder_program + '```')
|
| 222 |
# with st.container():
|
| 223 |
# st.write(binder_program)
|
| 224 |
executor = NSQLExecutor(args, keys=keys)
|
| 225 |
+
elif selected_language == 'Binder-Python':
|
| 226 |
st.code(binder_program, language='python')
|
| 227 |
executor = NPythonExecutor(args, keys=keys)
|
| 228 |
db = db.get_table_df()
|
|
|
|
| 233 |
os.makedirs('tmp_for_vis/', exist_ok=True)
|
| 234 |
with st.spinner("Executing... will be finished in 30s, please refresh the page if not"):
|
| 235 |
exec_answer = executor.nsql_exec(stamp, binder_program, db)
|
| 236 |
+
if selected_language == 'Binder-SQL':
|
| 237 |
with open("tmp_for_vis/{}_tmp_for_vis_steps.txt".format(stamp), "r") as f:
|
| 238 |
steps = json.load(f)
|
| 239 |
for i, step in enumerate(steps):
|
|
|
|
| 258 |
st.markdown('$\\rightarrow$')
|
| 259 |
if i == len(steps) - 1:
|
| 260 |
# The final step
|
| 261 |
+
st.markdown("{} Interpreter".format(selected_language.replace("Binder-", "")))
|
| 262 |
else:
|
| 263 |
st.markdown("GPT3 Codex")
|
| 264 |
with st.spinner('...'):
|
|
|
|
| 280 |
st.markdown(result_in_this_step)
|
| 281 |
with st.spinner('...'):
|
| 282 |
time.sleep(1)
|
| 283 |
+
elif selected_language == 'Binder-Python':
|
| 284 |
pass
|
| 285 |
if isinstance(exec_answer, list) and len(exec_answer) == 1:
|
| 286 |
exec_answer = exec_answer[0]
|