Spaces:
Sleeping
Sleeping
Commit
·
bde086b
1
Parent(s):
609c671
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,15 +22,19 @@ os.environ["HUGGINGFACEHUB_API_TOKEN"] = "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"
|
|
| 22 |
embedding = HuggingFaceHubEmbeddings()
|
| 23 |
|
| 24 |
loader = PyPDFLoader("sample.pdf")
|
| 25 |
-
|
| 26 |
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True) # to remember chat history include this
|
| 31 |
|
| 32 |
|
| 33 |
prompt_template = """Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
|
|
|
| 34 |
{context}
|
| 35 |
Question: {question}"""
|
| 36 |
|
|
|
|
| 22 |
embedding = HuggingFaceHubEmbeddings()
|
| 23 |
|
| 24 |
loader = PyPDFLoader("sample.pdf")
|
| 25 |
+
pdf = loader.load()
|
| 26 |
|
| 27 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
|
| 28 |
+
docs = text_splitter.split_documents(pdf)
|
| 29 |
+
|
| 30 |
+
vectorstore = Chroma.from_documents(documents=docs, embedding=embedding)
|
| 31 |
|
| 32 |
|
| 33 |
memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True) # to remember chat history include this
|
| 34 |
|
| 35 |
|
| 36 |
prompt_template = """Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
| 37 |
+
Answer with a single sentence
|
| 38 |
{context}
|
| 39 |
Question: {question}"""
|
| 40 |
|