Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,25 +22,23 @@ def process_with_markitdown(input_path):
|
|
22 |
|
23 |
def save_uploaded_file(uploaded_file):
|
24 |
"""Saves an uploaded file to a temporary location."""
|
25 |
-
|
26 |
if uploaded_file is None:
|
27 |
return "No file uploaded."
|
28 |
|
29 |
try:
|
|
|
|
|
30 |
temp_dir = tempfile.gettempdir()
|
31 |
-
temp_filename = os.path.join(temp_dir,
|
32 |
|
33 |
with open(temp_filename, 'wb') as f:
|
34 |
-
|
35 |
-
# Use 'read' to access the actual file content
|
36 |
-
f.write(uploaded_file.file.read())
|
37 |
-
except Exception as e:
|
38 |
-
return f"Error writing to file: {e}"
|
39 |
|
40 |
return temp_filename
|
|
|
41 |
except Exception as e:
|
42 |
-
return f"An error occurred: {e}"
|
43 |
-
|
44 |
async def summarize_text(text):
|
45 |
"""Summarize the input text using Gemini AI"""
|
46 |
try:
|
|
|
22 |
|
23 |
def save_uploaded_file(uploaded_file):
|
24 |
"""Saves an uploaded file to a temporary location."""
|
|
|
25 |
if uploaded_file is None:
|
26 |
return "No file uploaded."
|
27 |
|
28 |
try:
|
29 |
+
# Extract filename and file object from the tuple
|
30 |
+
filename, file_object = uploaded_file
|
31 |
temp_dir = tempfile.gettempdir()
|
32 |
+
temp_filename = os.path.join(temp_dir, filename)
|
33 |
|
34 |
with open(temp_filename, 'wb') as f:
|
35 |
+
f.write(file_object.read())
|
|
|
|
|
|
|
|
|
36 |
|
37 |
return temp_filename
|
38 |
+
|
39 |
except Exception as e:
|
40 |
+
return f"An error occurred: {str(e)}"
|
41 |
+
|
42 |
async def summarize_text(text):
|
43 |
"""Summarize the input text using Gemini AI"""
|
44 |
try:
|