Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,29 +20,27 @@ def process_with_markitdown(input_path):
|
|
20 |
except Exception as e:
|
21 |
return f"Error processing input: {str(e)}"
|
22 |
|
23 |
-
def save_uploaded_file(
|
24 |
-
"""Saves
|
25 |
|
26 |
-
if
|
27 |
return "No file uploaded."
|
28 |
|
29 |
try:
|
30 |
temp_dir = tempfile.gettempdir()
|
31 |
-
|
32 |
-
if file_data.name:
|
33 |
-
temp_filename = os.path.join(temp_dir, file_data.name)
|
34 |
-
else:
|
35 |
-
return "Error: File has no name."
|
36 |
-
|
37 |
|
38 |
with open(temp_filename, 'wb') as f:
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
return temp_filename
|
43 |
except Exception as e:
|
44 |
-
return f"An error occurred
|
45 |
-
|
46 |
async def summarize_text(text):
|
47 |
"""Summarize the input text using Gemini AI"""
|
48 |
try:
|
|
|
20 |
except Exception as e:
|
21 |
return f"Error processing input: {str(e)}"
|
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, uploaded_file.name)
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
with open(temp_filename, 'wb') as f:
|
34 |
+
try:
|
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:
|