Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,24 @@
|
|
1 |
-
|
2 |
-
import requests
|
3 |
-
from llama_index.core import VectorStoreIndex
|
4 |
-
from llama_index.readers.file import PDFReader
|
5 |
-
import gradio as gr
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
with open(destination, 'wb') as f:
|
12 |
-
f.write(response.content)
|
13 |
|
14 |
-
|
15 |
-
def create_index_from_pdf(pdf_path):
|
16 |
-
pdf_reader = PDFReader(pdf_path) # Pasar solo la ruta del archivo
|
17 |
-
documents = pdf_reader.load_data() # No abrir el archivo manualmente
|
18 |
-
|
19 |
-
# Crear el 铆ndice
|
20 |
-
index = VectorStoreIndex.from_documents(documents)
|
21 |
-
return index
|
22 |
-
|
23 |
-
# Ruta del archivo PDF a descargar
|
24 |
-
pdf_url = 'https://www.boe.es/buscar/pdf/1995/BOE-A-1995-25444-consolidado.pdf'
|
25 |
-
pdf_path = './BOE-A-1995-25444-consolidado.pdf'
|
26 |
-
|
27 |
-
# Descargar el PDF
|
28 |
-
download_pdf(pdf_url, pdf_path)
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
return
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
===== Application Startup at 2024-12-07 13:08:38 =====
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
Traceback (most recent call last):
|
4 |
+
File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 478, in __call__
|
5 |
+
result = fn(*args, **kwargs)
|
6 |
+
TypeError: PDFReader.load_data() missing 1 required positional argument: 'file'
|
|
|
|
|
7 |
|
8 |
+
The above exception was the direct cause of the following exception:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
Traceback (most recent call last):
|
11 |
+
File "/home/user/app/app.py", line 31, in <module>
|
12 |
+
index = create_index_from_pdf(pdf_path)
|
13 |
+
File "/home/user/app/app.py", line 17, in create_index_from_pdf
|
14 |
+
documents = pdf_reader.load_data() # No abrir el archivo manualmente
|
15 |
+
File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 336, in wrapped_f
|
16 |
+
return copy(f, *args, **kw)
|
17 |
+
File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 475, in __call__
|
18 |
+
do = self.iter(retry_state=retry_state)
|
19 |
+
File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 376, in iter
|
20 |
+
result = action(retry_state)
|
21 |
+
File "/usr/local/lib/python3.10/site-packages/tenacity/__init__.py", line 419, in exc_check
|
22 |
+
raise retry_exc from fut.exception()
|
23 |
+
tenacity.RetryError: RetryError[<Future at 0x7f53588abcd0 state=finished raised TypeError>]
|
24 |
+
|