Danielrahmai1991 commited on
Commit
095e948
·
verified ·
1 Parent(s): 3be163a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -37,8 +37,12 @@ def process_file(files, topic):
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
44
  file_path = file.name
@@ -51,6 +55,9 @@ def process_file(files, topic):
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
 
37
  'Error processing file: Unsupported file format. Only .docx, .txt, and .pdf are allowed.'
38
 
39
  """
40
+ progress = gr.Progress()
41
+
42
  log_history = [] # To store logs for each file
43
+ for i, file in enumerate(files):
44
+ progress(i / len(files), desc=f"Processing file {i + 1}/{len(files)}: {file_path}")
45
+
46
  try:
47
  # Read the file content
48
  file_path = file.name
 
55
  log_history.append( f"File {file_path} processed successfully! file saved to the database.")
56
  except Exception as e:
57
  log_history.append( f"Error processing for file {file_path}: {str(e)}")
58
+
59
+
60
+ progress(1.0, desc="Processing complete!")
61
  return "\n".join(log_history)
62
 
63
  # Define Gradio interface