Penality commited on
Commit
d680a93
·
verified ·
1 Parent(s): d133857

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -147,14 +147,19 @@ def retrieve_document(query):
147
 
148
  print(filename)
149
 
150
- pdf_file = requests.get(API_URL_FILES, params={"file":filename})
151
 
152
- print(pdf_file)
153
 
154
- # Read and return the document content
155
- with open(pdf_file, "r", encoding="utf-8") as f:
156
- return f.read()
 
 
 
157
 
 
 
158
  def clean_text(text):
159
  """Cleans extracted text for better processing by the model."""
160
  print("cleaning")
 
147
 
148
  print(filename)
149
 
150
+ response = requests.get(API_URL_FILES, params={"file":filename})
151
 
152
+ print(response)
153
 
154
+ if response.status_code == 200:
155
+ with open(filename, "wb") as f:
156
+ f.write(response.content)
157
+ print(f"File downloaded successfully: {filename}")
158
+ else:
159
+ print(f"Error: {response.status_code}, {response.json()}")
160
 
161
+ return filename
162
+
163
  def clean_text(text):
164
  """Cleans extracted text for better processing by the model."""
165
  print("cleaning")