Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ from langchain.chains import RetrievalQA
|
|
7 |
from langchain.prompts import PromptTemplate
|
8 |
from pdf2image import convert_from_path
|
9 |
import os
|
10 |
-
import
|
11 |
|
12 |
class LayoutLMv3OCR:
|
13 |
def __init__(self):
|
@@ -42,10 +42,10 @@ def process_pdf_and_query(pdf_path, question):
|
|
42 |
return response
|
43 |
|
44 |
def chatbot_response(pdf, question):
|
45 |
-
# Speichern der hochgeladenen PDF-Datei
|
46 |
pdf_path = "uploaded_pdf.pdf"
|
47 |
with open(pdf_path, "wb") as f:
|
48 |
-
f.write(pdf.read()) #
|
49 |
|
50 |
# OCR-Textextraktion
|
51 |
extracted_text = ocr_tool.extract_text(pdf_path)
|
|
|
7 |
from langchain.prompts import PromptTemplate
|
8 |
from pdf2image import convert_from_path
|
9 |
import os
|
10 |
+
import io # Für in-memory Dateioperationen
|
11 |
|
12 |
class LayoutLMv3OCR:
|
13 |
def __init__(self):
|
|
|
42 |
return response
|
43 |
|
44 |
def chatbot_response(pdf, question):
|
45 |
+
# Speichern der hochgeladenen PDF-Datei im Arbeitsspeicher
|
46 |
pdf_path = "uploaded_pdf.pdf"
|
47 |
with open(pdf_path, "wb") as f:
|
48 |
+
f.write(pdf.file.read()) # Hier wird der Inhalt der hochgeladenen Datei in eine PDF gespeichert
|
49 |
|
50 |
# OCR-Textextraktion
|
51 |
extracted_text = ocr_tool.extract_text(pdf_path)
|