la04 commited on
Commit
a40161a
·
verified ·
1 Parent(s): 24d5864

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
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 shutil
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 auf dem Server
46
  pdf_path = "uploaded_pdf.pdf"
47
  with open(pdf_path, "wb") as f:
48
- f.write(pdf.read()) # Speichert die hochgeladene PDF-Datei
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)