Commit
·
dc9ded5
1
Parent(s):
0e0d5d0
Update document_questioner_app.py
Browse files
document_questioner_app.py
CHANGED
|
@@ -13,8 +13,10 @@ from langchain.chat_models import ChatOpenAI
|
|
| 13 |
def question_document(Document, Question):
|
| 14 |
|
| 15 |
# loads a PDF document
|
|
|
|
|
|
|
| 16 |
if not Document.name.endswith('.pdf'):
|
| 17 |
-
|
| 18 |
|
| 19 |
loader = PyPDFLoader(Document.name)
|
| 20 |
docs = loader.load()
|
|
@@ -57,7 +59,7 @@ def question_document(Document, Question):
|
|
| 57 |
iface = gr.Interface(
|
| 58 |
fn = question_document,
|
| 59 |
inputs= ["file","text"],
|
| 60 |
-
outputs = gr.
|
| 61 |
title="Interrogateur de PDF",
|
| 62 |
description="par Nicolas \nPermet d'interroger un document PDF",
|
| 63 |
allow_flagging = "never")
|
|
|
|
| 13 |
def question_document(Document, Question):
|
| 14 |
|
| 15 |
# loads a PDF document
|
| 16 |
+
if not Document:
|
| 17 |
+
return "Merci de fournir un document PDF"
|
| 18 |
if not Document.name.endswith('.pdf'):
|
| 19 |
+
return ("Merci de fournir un document PDF")
|
| 20 |
|
| 21 |
loader = PyPDFLoader(Document.name)
|
| 22 |
docs = loader.load()
|
|
|
|
| 59 |
iface = gr.Interface(
|
| 60 |
fn = question_document,
|
| 61 |
inputs= ["file","text"],
|
| 62 |
+
outputs = gr.Textbox(label="Réponse"),
|
| 63 |
title="Interrogateur de PDF",
|
| 64 |
description="par Nicolas \nPermet d'interroger un document PDF",
|
| 65 |
allow_flagging = "never")
|