KyleIsaacs commited on
Commit
c689b3a
·
1 Parent(s): 213ec45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -22,10 +22,10 @@ os.environ["HUGGINGFACEHUB_API_TOKEN"] = "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"
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
 
@@ -34,6 +34,7 @@ memory = ConversationBufferMemory(memory_key="chat_history", return_messages=Tru
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
  {context}
38
  Question: {question}"""
39
 
@@ -58,4 +59,4 @@ if(prompt):
58
  st.write(f"{datetime.datetime.now()} :red[{option}:] ", prompt)
59
  context = qachain({"query": prompt})
60
 
61
- st.write(f"{datetime.datetime.now()}", context['result'])
 
22
  embedding = HuggingFaceHubEmbeddings()
23
 
24
  loader = PyPDFLoader("sample.pdf")
25
+ pages = loader.load_and_split()
26
 
27
  text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
28
+ docs = text_splitter.split_documents(pages)
29
 
30
  vectorstore = Chroma.from_documents(documents=docs, embedding=embedding)
31
 
 
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
 
 
59
  st.write(f"{datetime.datetime.now()} :red[{option}:] ", prompt)
60
  context = qachain({"query": prompt})
61
 
62
+ st.write(f"{datetime.datetime.now()}", context)