la04 commited on
Commit
adbd41e
·
verified ·
1 Parent(s): 20d1030

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -34,12 +34,7 @@ def search_documents(query, index, documents):
34
  return documents[I[0][0]] # Gibt das am besten passende Dokument zurück
35
 
36
  # Schritt 4: Gesamtprozess (Fragebeantwortung)
37
- def chatbot_response(pdf, question):
38
- # Speichern der hochgeladenen PDF als temporäre Datei
39
- pdf_path = "uploaded_pdf.pdf"
40
- with open(pdf_path, "wb") as f:
41
- f.write(pdf.read()) # Schreibe die PDF-Daten in eine temporäre Datei
42
-
43
  # Textextraktion aus der PDF
44
  text_pages = extract_text_from_pdf(pdf_path)
45
 
@@ -49,13 +44,10 @@ def chatbot_response(pdf, question):
49
  # Suche nach Antwort
50
  answer = search_documents(question, index, documents)
51
 
52
- # Lösche die hochgeladene PDF-Datei
53
- os.remove(pdf_path)
54
-
55
  return answer
56
 
57
  # Gradio-Interface
58
- pdf_input = gr.File(label="PDF-Datei hochladen", type="file")
59
  question_input = gr.Textbox(label="Frage eingeben", placeholder="Stelle eine Frage zu dem PDF-Dokument")
60
  response_output = gr.Textbox(label="Antwort")
61
 
 
34
  return documents[I[0][0]] # Gibt das am besten passende Dokument zurück
35
 
36
  # Schritt 4: Gesamtprozess (Fragebeantwortung)
37
+ def chatbot_response(pdf_path, question):
 
 
 
 
 
38
  # Textextraktion aus der PDF
39
  text_pages = extract_text_from_pdf(pdf_path)
40
 
 
44
  # Suche nach Antwort
45
  answer = search_documents(question, index, documents)
46
 
 
 
 
47
  return answer
48
 
49
  # Gradio-Interface
50
+ pdf_input = gr.File(label="PDF-Datei hochladen", type="filepath") # Ändert type="file" zu type="filepath"
51
  question_input = gr.Textbox(label="Frage eingeben", placeholder="Stelle eine Frage zu dem PDF-Dokument")
52
  response_output = gr.Textbox(label="Antwort")
53