Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ from langchain.text_splitter import CharacterTextSplitter
|
|
11 |
from langchain.vectorstores import Chroma # for the vectorization part
|
12 |
from langchain.chains import RetrievalQA # for conversing with chatGPT
|
13 |
from langchain.chat_models import ChatOpenAI # the LLM model we'll use (ChatGPT)
|
14 |
-
from
|
15 |
|
16 |
def load_pdf_and_generate_embeddings(pdf_doc, open_ai_key, relevant_pages):
|
17 |
# If an OpenAI API key is provided, it will be used for ChatOpenAI (GPT-4)
|
@@ -297,7 +297,7 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome()) as demo:
|
|
297 |
with gr.Tab("Chatbot"):
|
298 |
with gr.Column():
|
299 |
open_ai_key = gr.Textbox(label="Your GPT-4 OpenAI API key", type="password")
|
300 |
-
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type='
|
301 |
relevant_pages = gr.Textbox(label="*Optional - List comma separated page numbers to load or leave this field blank to use the entire PDF")
|
302 |
|
303 |
with gr.Row():
|
@@ -325,10 +325,10 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome()) as demo:
|
|
325 |
|
326 |
with gr.Tab("OCR Converter"):
|
327 |
with gr.Column():
|
328 |
-
image_pdf = gr.File(label="Load the pdf to be converted", file_types=['.pdf'], type='
|
329 |
|
330 |
with gr.Row():
|
331 |
-
ocr_pdf = gr.File(label="OCR'd pdf", file_types=['.pdf'], type='
|
332 |
convert_into_ocr = gr.Button("Convert").style(full_width=False)
|
333 |
|
334 |
with gr.Tab("Upload Question Set"):
|
@@ -591,7 +591,7 @@ with gr.Blocks(css=css, theme=gr.themes.Monochrome()) as demo:
|
|
591 |
]
|
592 |
document_type_for_questionset = gr.Dropdown(choices=document_types, label="Select the Document Type")
|
593 |
tag_for_questionset = gr.Textbox(label="Please provide a name for the question set. Ex: rwikd-dot-basic-questionset-20230707.")
|
594 |
-
csv_file = gr.File(label="Load a csv - 2 columns with the headers as field, question", file_types=['.csv'], type='
|
595 |
|
596 |
with gr.Row():
|
597 |
status_for_loading_csv = gr.Textbox(label="Status", placeholder="", interactive=False)
|
|
|
11 |
from langchain.vectorstores import Chroma # for the vectorization part
|
12 |
from langchain.chains import RetrievalQA # for conversing with chatGPT
|
13 |
from langchain.chat_models import ChatOpenAI # the LLM model we'll use (ChatGPT)
|
14 |
+
from langchain_core.prompts import PromptTemplate # updated import per warning
|
15 |
|
16 |
def load_pdf_and_generate_embeddings(pdf_doc, open_ai_key, relevant_pages):
|
17 |
# If an OpenAI API key is provided, it will be used for ChatOpenAI (GPT-4)
|
|
|
297 |
with gr.Tab("Chatbot"):
|
298 |
with gr.Column():
|
299 |
open_ai_key = gr.Textbox(label="Your GPT-4 OpenAI API key", type="password")
|
300 |
+
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type='filepath')
|
301 |
relevant_pages = gr.Textbox(label="*Optional - List comma separated page numbers to load or leave this field blank to use the entire PDF")
|
302 |
|
303 |
with gr.Row():
|
|
|
325 |
|
326 |
with gr.Tab("OCR Converter"):
|
327 |
with gr.Column():
|
328 |
+
image_pdf = gr.File(label="Load the pdf to be converted", file_types=['.pdf'], type='filepath')
|
329 |
|
330 |
with gr.Row():
|
331 |
+
ocr_pdf = gr.File(label="OCR'd pdf", file_types=['.pdf'], type='filepath', file_count="single")
|
332 |
convert_into_ocr = gr.Button("Convert").style(full_width=False)
|
333 |
|
334 |
with gr.Tab("Upload Question Set"):
|
|
|
591 |
]
|
592 |
document_type_for_questionset = gr.Dropdown(choices=document_types, label="Select the Document Type")
|
593 |
tag_for_questionset = gr.Textbox(label="Please provide a name for the question set. Ex: rwikd-dot-basic-questionset-20230707.")
|
594 |
+
csv_file = gr.File(label="Load a csv - 2 columns with the headers as field, question", file_types=['.csv'], type='filepath')
|
595 |
|
596 |
with gr.Row():
|
597 |
status_for_loading_csv = gr.Textbox(label="Status", placeholder="", interactive=False)
|