Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -75,7 +75,8 @@ def main():
|
|
| 75 |
def execute_instructor_code(params):
|
| 76 |
# Execute the instructor's code to get the result
|
| 77 |
globals_dict = {}
|
| 78 |
-
|
|
|
|
| 79 |
instructor_function = globals_dict.get(st.session_state.function_name)
|
| 80 |
|
| 81 |
if not callable(instructor_function):
|
|
@@ -85,10 +86,7 @@ def main():
|
|
| 85 |
|
| 86 |
# Generate sample examples dynamically by executing the instructor's code
|
| 87 |
sample_examples = "
|
| 88 |
-
".join(
|
| 89 |
-
[f"{st.session_state.function_name}({', '.join(map(str, params))}) -> {execute_instructor_code(params)}" for
|
| 90 |
-
params in
|
| 91 |
-
st.session_state.test_cases])
|
| 92 |
st.code(sample_examples, language="python")
|
| 93 |
show_solution_button = st.form_submit_button("Show Solution")
|
| 94 |
if show_solution_button:
|
|
|
|
| 75 |
def execute_instructor_code(params):
|
| 76 |
# Execute the instructor's code to get the result
|
| 77 |
globals_dict = {}
|
| 78 |
+
execdef sum(a,b):
|
| 79 |
+
return a+b, globals_dict)
|
| 80 |
instructor_function = globals_dict.get(st.session_state.function_name)
|
| 81 |
|
| 82 |
if not callable(instructor_function):
|
|
|
|
| 86 |
|
| 87 |
# Generate sample examples dynamically by executing the instructor's code
|
| 88 |
sample_examples = "
|
| 89 |
+
".join([f"{st.session_state.function_name}({', '.join(map(str, params))}) -> {execute_instructor_code(params)}" for params in st.session_state.test_cases])
|
|
|
|
|
|
|
|
|
|
| 90 |
st.code(sample_examples, language="python")
|
| 91 |
show_solution_button = st.form_submit_button("Show Solution")
|
| 92 |
if show_solution_button:
|