Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,9 +25,7 @@ def pdf_changes(pdf_doc, open_ai_key):
|
|
25 |
#To create a vector store, we use the Chroma class, which takes the documents (pages in our case), the embeddings instance, and a directory to store the vector data
|
26 |
vectordb = Chroma.from_documents(pages, embedding=embeddings)
|
27 |
|
28 |
-
#Finally, we create the bot using the
|
29 |
-
#A ConversationalRetrievalChain is similar to a RetrievalQAChain, except that the ConversationalRetrievalChain allows for
|
30 |
-
#passing in of a chat history which can be used to allow for follow up questions.
|
31 |
global pdf_qa
|
32 |
pdf_qa = RetrievalQA.from_chain_type(ChatOpenAI(temperature=0, model_name="gpt-4"), vectordb.as_retriever(), return_source_documents=False)
|
33 |
|
@@ -72,7 +70,7 @@ title = """
|
|
72 |
<h1>Chatbot for PDFs - GPT-4</h1>
|
73 |
<p style="text-align: center;">Upload a .PDF, click the "Load PDF to LangChain" button, <br />
|
74 |
Wait for the Status to show Ready, start typing your questions. <br />
|
75 |
-
The app is
|
76 |
</div>
|
77 |
"""
|
78 |
|
@@ -82,7 +80,7 @@ with gr.Blocks(css=css) as demo:
|
|
82 |
gr.HTML(title)
|
83 |
|
84 |
with gr.Column():
|
85 |
-
openai_key = gr.Textbox(label="Your OpenAI API key", type="password")
|
86 |
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type="file")
|
87 |
with gr.Row():
|
88 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
|
|
25 |
#To create a vector store, we use the Chroma class, which takes the documents (pages in our case), the embeddings instance, and a directory to store the vector data
|
26 |
vectordb = Chroma.from_documents(pages, embedding=embeddings)
|
27 |
|
28 |
+
#Finally, we create the bot using the RetrievalQAChain class
|
|
|
|
|
29 |
global pdf_qa
|
30 |
pdf_qa = RetrievalQA.from_chain_type(ChatOpenAI(temperature=0, model_name="gpt-4"), vectordb.as_retriever(), return_source_documents=False)
|
31 |
|
|
|
70 |
<h1>Chatbot for PDFs - GPT-4</h1>
|
71 |
<p style="text-align: center;">Upload a .PDF, click the "Load PDF to LangChain" button, <br />
|
72 |
Wait for the Status to show Ready, start typing your questions. <br />
|
73 |
+
The app is built on GPT-4</p>
|
74 |
</div>
|
75 |
"""
|
76 |
|
|
|
80 |
gr.HTML(title)
|
81 |
|
82 |
with gr.Column():
|
83 |
+
openai_key = gr.Textbox(label="Your GPT-4 OpenAI API key", type="password")
|
84 |
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type="file")
|
85 |
with gr.Row():
|
86 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
|