Spaces:
Runtime error
Runtime error
Add multiple file upload
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ def pdf_changes(pdf_doc, open_ai_key):
|
|
33 |
qa = ConversationalRetrievalChain.from_llm(
|
34 |
llm=OpenAI(temperature=0.5),
|
35 |
retriever=retriever,
|
36 |
-
return_source_documents=
|
37 |
return "Ready"
|
38 |
else:
|
39 |
return "You forgot OpenAI API key"
|
@@ -52,8 +52,7 @@ def bot(history):
|
|
52 |
yield history
|
53 |
|
54 |
|
55 |
-
def infer(question, history):
|
56 |
-
|
57 |
res = []
|
58 |
for human, ai in history[:-1]:
|
59 |
pair = (human, ai)
|
@@ -72,10 +71,8 @@ css="""
|
|
72 |
|
73 |
title = """
|
74 |
<div style="text-align: center;max-width: 700px;">
|
75 |
-
<h1>
|
76 |
-
<p style="text-align: center;">
|
77 |
-
when everything is ready, you can start asking questions about the pdf ;) <br />
|
78 |
-
This version is set to store chat history, and uses OpenAI as LLM, don't forget to copy/paste your OpenAI API key</p>
|
79 |
</div>
|
80 |
"""
|
81 |
|
@@ -86,7 +83,7 @@ with gr.Blocks(css=css) as demo:
|
|
86 |
|
87 |
with gr.Column():
|
88 |
openai_key = gr.Textbox(label="You OpenAI API key", type="password")
|
89 |
-
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type="file")
|
90 |
with gr.Row():
|
91 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
92 |
load_pdf = gr.Button("Load pdf to langchain")
|
@@ -94,6 +91,7 @@ with gr.Blocks(css=css) as demo:
|
|
94 |
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
|
95 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
|
96 |
submit_btn = gr.Button("Send Message")
|
|
|
97 |
load_pdf.click(loading_pdf, None, langchain_status, queue=False)
|
98 |
load_pdf.click(pdf_changes, inputs=[pdf_doc, openai_key], outputs=[langchain_status], queue=False)
|
99 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(
|
|
|
33 |
qa = ConversationalRetrievalChain.from_llm(
|
34 |
llm=OpenAI(temperature=0.5),
|
35 |
retriever=retriever,
|
36 |
+
return_source_documents=True)
|
37 |
return "Ready"
|
38 |
else:
|
39 |
return "You forgot OpenAI API key"
|
|
|
52 |
yield history
|
53 |
|
54 |
|
55 |
+
def infer(question, history):
|
|
|
56 |
res = []
|
57 |
for human, ai in history[:-1]:
|
58 |
pair = (human, ai)
|
|
|
71 |
|
72 |
title = """
|
73 |
<div style="text-align: center;max-width: 700px;">
|
74 |
+
<h1>YnP LangChain Test </h1>
|
75 |
+
<p style="text-align: center;">Please specify OpenAI Key before use</p>
|
|
|
|
|
76 |
</div>
|
77 |
"""
|
78 |
|
|
|
83 |
|
84 |
with gr.Column():
|
85 |
openai_key = gr.Textbox(label="You OpenAI API key", type="password")
|
86 |
+
pdf_doc = gr.File(label="Load a pdf", file_count="multiple", file_types=['.pdf'], type="file")
|
87 |
with gr.Row():
|
88 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
89 |
load_pdf = gr.Button("Load pdf to langchain")
|
|
|
91 |
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
|
92 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
|
93 |
submit_btn = gr.Button("Send Message")
|
94 |
+
|
95 |
load_pdf.click(loading_pdf, None, langchain_status, queue=False)
|
96 |
load_pdf.click(pdf_changes, inputs=[pdf_doc, openai_key], outputs=[langchain_status], queue=False)
|
97 |
question.submit(add_text, [chatbot, question], [chatbot, question]).then(
|