cstr commited on
Commit
030aaa2
·
verified ·
1 Parent(s): d2a93c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -252,9 +252,14 @@ def send_to_model_impl(prompt, model_selection, hf_model_choice, hf_custom_model
252
  else:
253
  return "Error: Invalid model selection", None
254
 
255
- with tempfile.NamedTemporaryFile(delete=False, mode='w', suffix='.txt') as f:
256
- f.write(summary)
257
- download_file = f.name
 
 
 
 
 
258
 
259
  return summary, download_file
260
 
 
252
  else:
253
  return "Error: Invalid model selection", None
254
 
255
+ try: # for file operations
256
+ with tempfile.NamedTemporaryFile(mode='w+', suffix='.txt', delete=False) as f: # w+ for write and read
257
+ f.write(summary)
258
+ f.flush() # Ensure data is written to disk
259
+ f.seek(0) # Rewind to the beginning of the file
260
+ download_file = f.name
261
+ except Exception as file_error:
262
+ return f"Error creating summary file: {file_error}", None
263
 
264
  return summary, download_file
265