Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ from langchain.vectorstores import FAISS
|
|
6 |
from langchain.llms import HuggingFaceHub
|
7 |
from langchain.chains import RetrievalQA
|
8 |
from datasets import load_dataset
|
9 |
-
import torch
|
10 |
import os
|
11 |
|
12 |
key = os.environ.get('RLS')
|
@@ -37,7 +36,7 @@ def pdf_changes(pdf_doc):
|
|
37 |
return "Ready"
|
38 |
|
39 |
def book_changes(book):
|
40 |
-
db =
|
41 |
llm=HuggingFaceHub(repo_id="google/flan-t5-xxl", model_kwargs={"temperature":1, "max_length":1000000})
|
42 |
global qa
|
43 |
qa = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=db.as_retriever(search_kwargs={"k": 3}))
|
@@ -77,7 +76,7 @@ with gr.Blocks(css=css) as demo:
|
|
77 |
with gr.Column():
|
78 |
pdf_doc = gr.File(label="Load a PDF", file_types=['.pdf'], type="file")
|
79 |
load_pdf = gr.Button("Load PDF")
|
80 |
-
Books = gr.Dropdown(label="Books", choices=[("Book 1","Book1.
|
81 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
82 |
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
|
83 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
|
|
|
6 |
from langchain.llms import HuggingFaceHub
|
7 |
from langchain.chains import RetrievalQA
|
8 |
from datasets import load_dataset
|
|
|
9 |
import os
|
10 |
|
11 |
key = os.environ.get('RLS')
|
|
|
36 |
return "Ready"
|
37 |
|
38 |
def book_changes(book):
|
39 |
+
db = FAISS.load_local( book , embeddings = HuggingFaceHubEmbeddings() )
|
40 |
llm=HuggingFaceHub(repo_id="google/flan-t5-xxl", model_kwargs={"temperature":1, "max_length":1000000})
|
41 |
global qa
|
42 |
qa = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff", retriever=db.as_retriever(search_kwargs={"k": 3}))
|
|
|
76 |
with gr.Column():
|
77 |
pdf_doc = gr.File(label="Load a PDF", file_types=['.pdf'], type="file")
|
78 |
load_pdf = gr.Button("Load PDF")
|
79 |
+
Books = gr.Dropdown(label="Books", choices=[("Book 1","Book1.faiss") , ("Book 2","Book2.faiss") , ("Book 3","Book3.faiss")] )
|
80 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
|
81 |
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
|
82 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
|