Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -281,19 +281,20 @@ def create_file(filename, prompt, response, should_save=True):
|
|
| 281 |
if not should_save:
|
| 282 |
return
|
| 283 |
base_filename, ext = os.path.splitext(filename)
|
| 284 |
-
has_python_code = re.search(r"```python([\s\S]*?)```", prompt.strip() + '\r\n' + response)
|
| 285 |
-
has_python_code = bool(re.search(r"```python([\s\S]*?)```", prompt.strip() + '\r\n' + response))
|
| 286 |
if ext in ['.txt', '.htm', '.md']:
|
| 287 |
with open(f"{base_filename}.md", 'w') as file:
|
| 288 |
content = prompt.strip() + '\r\n' + response
|
| 289 |
file.write(content)
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
|
|
|
|
|
|
|
|
|
| 297 |
|
| 298 |
def truncate_document(document, length):
|
| 299 |
return document[:length]
|
|
|
|
| 281 |
if not should_save:
|
| 282 |
return
|
| 283 |
base_filename, ext = os.path.splitext(filename)
|
|
|
|
|
|
|
| 284 |
if ext in ['.txt', '.htm', '.md']:
|
| 285 |
with open(f"{base_filename}.md", 'w') as file:
|
| 286 |
content = prompt.strip() + '\r\n' + response
|
| 287 |
file.write(content)
|
| 288 |
+
|
| 289 |
+
#has_python_code = re.search(r"```python([\s\S]*?)```", prompt.strip() + '\r\n' + response)
|
| 290 |
+
#has_python_code = bool(re.search(r"```python([\s\S]*?)```", prompt.strip() + '\r\n' + response))
|
| 291 |
+
#if has_python_code:
|
| 292 |
+
# python_code = re.findall(r"```python([\s\S]*?)```", response)[0].strip()
|
| 293 |
+
# with open(f"{base_filename}-Code.py", 'w') as file:
|
| 294 |
+
# file.write(python_code)
|
| 295 |
+
# with open(f"{base_filename}.md", 'w') as file:
|
| 296 |
+
# content = prompt.strip() + '\r\n' + response
|
| 297 |
+
# file.write(content)
|
| 298 |
|
| 299 |
def truncate_document(document, length):
|
| 300 |
return document[:length]
|