Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,9 @@ def process_file(files, topic):
|
|
35 |
|
36 |
>>> process_file(unsupported_file, ["Science"])
|
37 |
'Error processing file: Unsupported file format. Only .docx, .txt, and .pdf are allowed.'
|
|
|
38 |
"""
|
|
|
39 |
for file in files:
|
40 |
try:
|
41 |
# Read the file content
|
@@ -46,9 +48,10 @@ def process_file(files, topic):
|
|
46 |
# Save chunks to database
|
47 |
save_to_db([text], topic)
|
48 |
|
49 |
-
|
50 |
except Exception as e:
|
51 |
-
|
|
|
52 |
|
53 |
# Define Gradio interface
|
54 |
with gr.Blocks() as demo:
|
|
|
35 |
|
36 |
>>> process_file(unsupported_file, ["Science"])
|
37 |
'Error processing file: Unsupported file format. Only .docx, .txt, and .pdf are allowed.'
|
38 |
+
|
39 |
"""
|
40 |
+
log_history = [] # To store logs for each file
|
41 |
for file in files:
|
42 |
try:
|
43 |
# Read the file content
|
|
|
48 |
# Save chunks to database
|
49 |
save_to_db([text], topic)
|
50 |
|
51 |
+
log_history.append( f"File {file_path} processed successfully! file saved to the database.")
|
52 |
except Exception as e:
|
53 |
+
log_history.append( f"Error processing for file {file_path}: {str(e)}")
|
54 |
+
return "\n".join(log_history)
|
55 |
|
56 |
# Define Gradio interface
|
57 |
with gr.Blocks() as demo:
|