ErikH commited on
Commit
900a2bf
1 Parent(s): 05680a2

Update pages/bot.py

Browse files
Files changed (1) hide show
  1. pages/bot.py +7 -0
pages/bot.py CHANGED
@@ -5,6 +5,7 @@ from langchain.text_splitter import CharacterTextSplitter
5
  from langchain.document_loaders import DirectoryLoader, PyPDFLoader
6
  import os
7
  from PyPDF2 import PdfReader
 
8
 
9
  ###########
10
  #pip install faiss-cpu
@@ -80,6 +81,12 @@ def main():
80
  )
81
  if user_question:
82
  st.text(retrieved_docs[0].page_content)
 
 
 
 
 
 
83
  # bei incoming pdf
84
 
85
  #vectorstore_DB=get_vectorstore() # bei Abfrage durch Chatbot
 
5
  from langchain.document_loaders import DirectoryLoader, PyPDFLoader
6
  import os
7
  from PyPDF2 import PdfReader
8
+ from transformers import pipeline
9
 
10
  ###########
11
  #pip install faiss-cpu
 
81
  )
82
  if user_question:
83
  st.text(retrieved_docs[0].page_content)
84
+ qa_pipeline = pipeline("question-answering", model="hkunlp/instructor-base", tokenizer="hkunlp/instructor-base")
85
+ context=retrieved_docs[0].page_content
86
+ question=user_question
87
+ answer = qa_pipeline(question=question, context=context)
88
+ st.text("FORMATIERTE ANTWORT:")
89
+ st.text(answer)
90
  # bei incoming pdf
91
 
92
  #vectorstore_DB=get_vectorstore() # bei Abfrage durch Chatbot