Spaces:
Runtime error
Runtime error
test
Browse files- app/main.py +7 -0
- requirements.txt +2 -1
app/main.py
CHANGED
@@ -9,6 +9,7 @@ from fastapi.middleware import Middleware
|
|
9 |
from fastapi.middleware.cors import CORSMiddleware
|
10 |
from fastapi.responses import StreamingResponse
|
11 |
from .rag import ChatPDF
|
|
|
12 |
|
13 |
middleware = [
|
14 |
Middleware(
|
@@ -64,6 +65,12 @@ def upload(data: bytes = Depends(parse_body)):
|
|
64 |
path = f"{files_dir}/file.pdf"
|
65 |
with open(path, "wb") as f:
|
66 |
f.write(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
session_assistant.ingest(files_dir)
|
68 |
pathlib.Path(path).unlink()
|
69 |
except Exception as e:
|
|
|
9 |
from fastapi.middleware.cors import CORSMiddleware
|
10 |
from fastapi.responses import StreamingResponse
|
11 |
from .rag import ChatPDF
|
12 |
+
import pdfplumber
|
13 |
|
14 |
middleware = [
|
15 |
Middleware(
|
|
|
65 |
path = f"{files_dir}/file.pdf"
|
66 |
with open(path, "wb") as f:
|
67 |
f.write(data)
|
68 |
+
# with open(path, "wb") as f:
|
69 |
+
pdf = pdfplumber.open(path)
|
70 |
+
page = pdf.pages[0]
|
71 |
+
text = page.extract_text()
|
72 |
+
print(text)
|
73 |
+
pdf.close()
|
74 |
session_assistant.ingest(files_dir)
|
75 |
pathlib.Path(path).unlink()
|
76 |
except Exception as e:
|
requirements.txt
CHANGED
@@ -6,4 +6,5 @@ llama-index-llms-llama-cpp
|
|
6 |
llama-index-embeddings-fastembed
|
7 |
qdrant-client
|
8 |
unstructured
|
9 |
-
fastembed==0.2.7
|
|
|
|
6 |
llama-index-embeddings-fastembed
|
7 |
qdrant-client
|
8 |
unstructured
|
9 |
+
fastembed==0.2.7
|
10 |
+
pdfplumber
|