NaimaAqeel commited on
Commit
b3c97dd
·
verified ·
1 Parent(s): 7000461

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -82,7 +82,11 @@ def upload_files(files):
82
  try:
83
  for file in files:
84
  try:
85
- file_path = file.name
 
 
 
 
86
  if file_path.endswith('.pdf'):
87
  text = extract_text_from_pdf(file_path)
88
  elif file_path.endswith('.docx'):
@@ -97,7 +101,7 @@ def upload_files(files):
97
  state["sentences"].extend(sentences)
98
 
99
  except Exception as e:
100
- print(f"Error processing file '{file.name}': {e}")
101
  return {"error": str(e)}
102
 
103
  # Save the updated index
@@ -152,6 +156,6 @@ with gr.Blocks() as demo:
152
  query = gr.Textbox(label="Enter your query")
153
  query_button = gr.Button("Search")
154
  query_output = gr.Textbox()
155
- query_button.click(fn=process_and_query, inputs=[upload, query], outputs=query_output)
156
 
157
  demo.launch()
 
82
  try:
83
  for file in files:
84
  try:
85
+ if isinstance(file, str):
86
+ file_path = file
87
+ else:
88
+ file_path = file.name
89
+
90
  if file_path.endswith('.pdf'):
91
  text = extract_text_from_pdf(file_path)
92
  elif file_path.endswith('.docx'):
 
101
  state["sentences"].extend(sentences)
102
 
103
  except Exception as e:
104
+ print(f"Error processing file '{file}': {e}")
105
  return {"error": str(e)}
106
 
107
  # Save the updated index
 
156
  query = gr.Textbox(label="Enter your query")
157
  query_button = gr.Button("Search")
158
  query_output = gr.Textbox()
159
+ query_button.click(fn=process_and_query, inputs=[query], outputs=query_output)
160
 
161
  demo.launch()