Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
| 256 |
-
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|