awacke1 commited on
Commit
001a7fd
1 Parent(s): dad973e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
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
- if has_python_code:
291
- python_code = re.findall(r"```python([\s\S]*?)```", response)[0].strip()
292
- with open(f"{base_filename}-Code.py", 'w') as file:
293
- file.write(python_code)
294
- with open(f"{base_filename}.md", 'w') as file:
295
- content = prompt.strip() + '\r\n' + response
296
- file.write(content)
 
 
 
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]