Danielrahmai1991 commited on
Commit
69fb57b
·
verified ·
1 Parent(s): ec8b41b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
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
- return f"File {file_path} processed successfully! file saved to the database."
50
  except Exception as e:
51
- return f"Error processing for file {file_path}: {str(e)}"
 
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: