MaxGit32 commited on
Commit
6c39a29
·
1 Parent(s): 22b609a

Update pages/llm.py

Browse files
Files changed (1) hide show
  1. pages/llm.py +5 -4
pages/llm.py CHANGED
@@ -33,8 +33,9 @@ def get_pdf_text(folder_path):
33
  for page in pdf_reader.pages:
34
  text += page.extract_text()
35
  #text += '\n'
36
-
37
- return translator.translate(text, src='de',dest ='en').text
 
38
 
39
  #Chunks erstellen
40
  def get_text_chunks(text):
@@ -80,7 +81,7 @@ def get_llm_answer(user_question):
80
  #if os.path.exists("./Store"): #Nutzereingabe nur eingelesen, wenn vectorstore angelegt
81
  # Retriever sucht passende Textausschnitte in den PDFs (unformatiert)
82
  translator = Translator()
83
- translator.translate(user_question, src='de',dest='en')
84
  retriever=get_vectorstore().as_retriever()
85
  retrieved_docs=retriever.invoke(
86
  user_question
@@ -97,7 +98,7 @@ def get_llm_answer(user_question):
97
  # Frage beantworten mit Q&A Pipeline
98
  answer = qa_pipeline(question=user_question, context=context, max_length=200)
99
 
100
- return translator.translate(answer["answer"], src='en', dest='de')
101
 
102
  def main():
103
  st.set_page_config(
 
33
  for page in pdf_reader.pages:
34
  text += page.extract_text()
35
  #text += '\n'
36
+ text=text.replace("\n", " ")
37
+ text=text.replace("- ", "")
38
+ return translator.translate(text, dest ='en').text
39
 
40
  #Chunks erstellen
41
  def get_text_chunks(text):
 
81
  #if os.path.exists("./Store"): #Nutzereingabe nur eingelesen, wenn vectorstore angelegt
82
  # Retriever sucht passende Textausschnitte in den PDFs (unformatiert)
83
  translator = Translator()
84
+ translator.translate(user_question, dest='en')
85
  retriever=get_vectorstore().as_retriever()
86
  retrieved_docs=retriever.invoke(
87
  user_question
 
98
  # Frage beantworten mit Q&A Pipeline
99
  answer = qa_pipeline(question=user_question, context=context, max_length=200)
100
 
101
+ return translator.translate(answer["answer"],dest='de')
102
 
103
  def main():
104
  st.set_page_config(