Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
2 |
from langchain import PromptTemplate
|
3 |
-
from
|
4 |
from langchain_community.vectorstores import FAISS
|
5 |
from langchain.chains import RetrievalQA
|
6 |
-
from
|
7 |
-
from langchain.chains.question_answering import load_qa_chain
|
8 |
import gradio as gr
|
9 |
|
10 |
DB_FAISS_PATH = "vectorstores/db_faiss"
|
@@ -55,9 +54,9 @@ Helpful answer:
|
|
55 |
|
56 |
def retrieval_QA_chain(llm, prompt, db):
|
57 |
"""
|
58 |
-
Create a RetrievalQA chain with the specified LLM, prompt, and vector store.
|
59 |
"""
|
60 |
-
llm_chain =
|
61 |
qachain = RetrievalQA.from_chain_type(
|
62 |
llm_chain=llm_chain,
|
63 |
chain_type="stuff",
|
|
|
1 |
from transformers import GPT2LMHeadModel, GPT2Tokenizer
|
2 |
from langchain import PromptTemplate
|
3 |
+
from langchain_huggingface import HuggingFaceEmbeddings
|
4 |
from langchain_community.vectorstores import FAISS
|
5 |
from langchain.chains import RetrievalQA
|
6 |
+
from langchain_core import RunnableSequence
|
|
|
7 |
import gradio as gr
|
8 |
|
9 |
DB_FAISS_PATH = "vectorstores/db_faiss"
|
|
|
54 |
|
55 |
def retrieval_QA_chain(llm, prompt, db):
|
56 |
"""
|
57 |
+
Create a RetrievalQA chain with the specified LLM, prompt, and vector store using the updated RunnableSequence.
|
58 |
"""
|
59 |
+
llm_chain = RunnableSequence([prompt, llm])
|
60 |
qachain = RetrievalQA.from_chain_type(
|
61 |
llm_chain=llm_chain,
|
62 |
chain_type="stuff",
|