Spaces:
Sleeping
Sleeping
updated app with new code
Browse files
app.py
CHANGED
|
@@ -5,10 +5,14 @@ from langchain.document_loaders import OnlinePDFLoader
|
|
| 5 |
from langchain.text_splitter import CharacterTextSplitter
|
| 6 |
from langchain.prompts import PromptTemplate
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
text_splitter = CharacterTextSplitter(chunk_size=350, chunk_overlap=0)
|
| 9 |
|
| 10 |
from langchain.llms import HuggingFaceHub
|
| 11 |
flan_ul2 = HuggingFaceHub(repo_id="HuggingFaceH4/zephyr-7b-beta", model_kwargs={"temperature":0.1, "max_new_tokens":300})
|
|
|
|
| 12 |
|
| 13 |
from langchain.embeddings import HuggingFaceHubEmbeddings
|
| 14 |
embeddings = HuggingFaceHubEmbeddings()
|
|
@@ -81,12 +85,12 @@ with gr.Blocks(css=css) as demo:
|
|
| 81 |
gr.HTML(title)
|
| 82 |
|
| 83 |
with gr.Column():
|
| 84 |
-
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type="
|
| 85 |
with gr.Row():
|
| 86 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
| 87 |
load_pdf = gr.Button("Load pdf to langchain")
|
| 88 |
|
| 89 |
-
chatbot = gr.Chatbot([], elem_id="chatbot")
|
| 90 |
with gr.Row():
|
| 91 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
|
| 92 |
load_pdf.click(loading_pdf, None, langchain_status, queue=False)
|
|
|
|
| 5 |
from langchain.text_splitter import CharacterTextSplitter
|
| 6 |
from langchain.prompts import PromptTemplate
|
| 7 |
|
| 8 |
+
# from langhchain.llms import openai
|
| 9 |
+
from langchain.llms import OpenAI
|
| 10 |
+
|
| 11 |
text_splitter = CharacterTextSplitter(chunk_size=350, chunk_overlap=0)
|
| 12 |
|
| 13 |
from langchain.llms import HuggingFaceHub
|
| 14 |
flan_ul2 = HuggingFaceHub(repo_id="HuggingFaceH4/zephyr-7b-beta", model_kwargs={"temperature":0.1, "max_new_tokens":300})
|
| 15 |
+
# flan_ul2 = OpenAI()
|
| 16 |
|
| 17 |
from langchain.embeddings import HuggingFaceHubEmbeddings
|
| 18 |
embeddings = HuggingFaceHubEmbeddings()
|
|
|
|
| 85 |
gr.HTML(title)
|
| 86 |
|
| 87 |
with gr.Column():
|
| 88 |
+
pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type="filepath") #try filepath for type if binary does not work
|
| 89 |
with gr.Row():
|
| 90 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
| 91 |
load_pdf = gr.Button("Load pdf to langchain")
|
| 92 |
|
| 93 |
+
chatbot = gr.Chatbot([], elem_id="chatbot") #.style(height=350)
|
| 94 |
with gr.Row():
|
| 95 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
|
| 96 |
load_pdf.click(loading_pdf, None, langchain_status, queue=False)
|