Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ from langchain.chains import ConversationalRetrievalChain
|
|
11 |
#from htmlTemplates import css, bot_template, user_template
|
12 |
from langchain.llms import HuggingFaceHub
|
13 |
from dotenv import load_dotenv
|
|
|
14 |
###########
|
15 |
#pip install faiss-cpu
|
16 |
#pip install langchain
|
@@ -19,6 +20,14 @@ from dotenv import load_dotenv
|
|
19 |
#pip install InstructorEmbedding
|
20 |
###############
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# PDF in String umwandeln
|
23 |
def get_pdf_text(folder_path):
|
24 |
text = ""
|
@@ -72,9 +81,16 @@ def get_vectorstore():
|
|
72 |
return vectorstoreDB
|
73 |
|
74 |
|
|
|
|
|
75 |
def main():
|
76 |
load_dotenv()
|
77 |
user_question = st.text_area("Eingabe:")
|
|
|
|
|
|
|
|
|
|
|
78 |
folder_path = './PDFs'
|
79 |
pdf_text = get_pdf_text(folder_path)
|
80 |
text_chunks = get_text_chunks(pdf_text)
|
|
|
11 |
#from htmlTemplates import css, bot_template, user_template
|
12 |
from langchain.llms import HuggingFaceHub
|
13 |
from dotenv import load_dotenv
|
14 |
+
from transformers import pipeline
|
15 |
###########
|
16 |
#pip install faiss-cpu
|
17 |
#pip install langchain
|
|
|
20 |
#pip install InstructorEmbedding
|
21 |
###############
|
22 |
|
23 |
+
def check_question(user_question):
|
24 |
+
# Hier deine Logik für die Überprüfung der Frage auf Genauigkeit
|
25 |
+
# Zum Beispiel könntest du die Länge der Frage überprüfen oder nach bestimmten Schlüsselwörtern suchen
|
26 |
+
# Du könntest auch ein NLP-Modell verwenden, um die Relevanz der Frage zu bewerten
|
27 |
+
if len(user_question) < 10: # Beispielkriterium für minimale Länge
|
28 |
+
return False
|
29 |
+
return True
|
30 |
+
|
31 |
# PDF in String umwandeln
|
32 |
def get_pdf_text(folder_path):
|
33 |
text = ""
|
|
|
81 |
return vectorstoreDB
|
82 |
|
83 |
|
84 |
+
|
85 |
+
|
86 |
def main():
|
87 |
load_dotenv()
|
88 |
user_question = st.text_area("Eingabe:")
|
89 |
+
|
90 |
+
if not check_question(user_question):
|
91 |
+
st.error("Die Frage ist zu ungenau. Bitte präzisiere deine Frage.")
|
92 |
+
return
|
93 |
+
|
94 |
folder_path = './PDFs'
|
95 |
pdf_text = get_pdf_text(folder_path)
|
96 |
text_chunks = get_text_chunks(pdf_text)
|