Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -78,9 +78,7 @@ def create_file(filename, prompt, response, should_save=True):
|
|
| 78 |
if "python" in resource.lower():
|
| 79 |
# Remove the 'python' keyword from the code block
|
| 80 |
cleaned_code = re.sub(r'^\s*python', '', resource, flags=re.IGNORECASE | re.MULTILINE)
|
| 81 |
-
|
| 82 |
-
# Add Code Results title with markdown and emoji
|
| 83 |
-
combined_content += "# Code Results π\n"
|
| 84 |
|
| 85 |
# Redirect standard output to capture it
|
| 86 |
original_stdout = sys.stdout
|
|
@@ -91,7 +89,7 @@ def create_file(filename, prompt, response, should_save=True):
|
|
| 91 |
exec(cleaned_code, context)
|
| 92 |
code_output = sys.stdout.getvalue()
|
| 93 |
combined_content += f"```\n{code_output}\n```\n\n"
|
| 94 |
-
realtimeEvalResponse = "
|
| 95 |
st.write(realtimeEvalResponse)
|
| 96 |
|
| 97 |
except Exception as e:
|
|
@@ -101,7 +99,7 @@ def create_file(filename, prompt, response, should_save=True):
|
|
| 101 |
sys.stdout = original_stdout
|
| 102 |
else:
|
| 103 |
# Add non-Python resources with markdown and emoji
|
| 104 |
-
combined_content += "
|
| 105 |
|
| 106 |
# Save the combined content to a Markdown file
|
| 107 |
if should_save:
|
|
|
|
| 78 |
if "python" in resource.lower():
|
| 79 |
# Remove the 'python' keyword from the code block
|
| 80 |
cleaned_code = re.sub(r'^\s*python', '', resource, flags=re.IGNORECASE | re.MULTILINE)
|
| 81 |
+
combined_content += "### Code Execution Results π\n"
|
|
|
|
|
|
|
| 82 |
|
| 83 |
# Redirect standard output to capture it
|
| 84 |
original_stdout = sys.stdout
|
|
|
|
| 89 |
exec(cleaned_code, context)
|
| 90 |
code_output = sys.stdout.getvalue()
|
| 91 |
combined_content += f"```\n{code_output}\n```\n\n"
|
| 92 |
+
realtimeEvalResponse = "### Code Execution Results π\n" + "```" + code_output + "```\n\n"
|
| 93 |
st.write(realtimeEvalResponse)
|
| 94 |
|
| 95 |
except Exception as e:
|
|
|
|
| 99 |
sys.stdout = original_stdout
|
| 100 |
else:
|
| 101 |
# Add non-Python resources with markdown and emoji
|
| 102 |
+
combined_content += "### Resource Added For New Tool π οΈ\n" + "```" + resource + "```\n\n"
|
| 103 |
|
| 104 |
# Save the combined content to a Markdown file
|
| 105 |
if should_save:
|