Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,10 @@ from langchain.document_loaders import OnlinePDFLoader
|
|
5 |
from langchain.text_splitter import CharacterTextSplitter
|
6 |
text_splitter = CharacterTextSplitter(chunk_size=350, chunk_overlap=0)
|
7 |
|
8 |
-
from langchain.llms import
|
9 |
-
flan_ul2 = HuggingFaceHub(repo_id="google/flan-ul2", model_kwargs={"temperature":0.1, "max_new_tokens":300})
|
10 |
|
11 |
-
from langchain.embeddings import
|
12 |
-
embeddings =
|
13 |
|
14 |
from langchain.vectorstores import Chroma
|
15 |
|
@@ -23,7 +22,7 @@ def pdf_changes(pdf_doc):
|
|
23 |
db = Chroma.from_documents(texts, embeddings)
|
24 |
retriever = db.as_retriever()
|
25 |
global qa
|
26 |
-
qa = RetrievalQA.from_chain_type(llm=
|
27 |
return "Ready"
|
28 |
|
29 |
def add_text(history, text):
|
|
|
5 |
from langchain.text_splitter import CharacterTextSplitter
|
6 |
text_splitter = CharacterTextSplitter(chunk_size=350, chunk_overlap=0)
|
7 |
|
8 |
+
from langchain.llms import OpenAI
|
|
|
9 |
|
10 |
+
from langchain.embeddings import OpenAIEmbeddings
|
11 |
+
embeddings = OpenAIEmbeddings()
|
12 |
|
13 |
from langchain.vectorstores import Chroma
|
14 |
|
|
|
22 |
db = Chroma.from_documents(texts, embeddings)
|
23 |
retriever = db.as_retriever()
|
24 |
global qa
|
25 |
+
qa = RetrievalQA.from_chain_type(llm=OpenAI(), chain_type="stuff", retriever=retriever, return_source_documents=True)
|
26 |
return "Ready"
|
27 |
|
28 |
def add_text(history, text):
|