Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,3 @@
|
|
1 |
-
# #############################################################################################################################
|
2 |
-
# # Filename : app.py
|
3 |
-
# # Description: A Streamlit application to showcase how RAG works.
|
4 |
-
# # Author : Georgios Ioannou
|
5 |
-
# #
|
6 |
-
# # Copyright © 2024 by Georgios Ioannou
|
7 |
-
# #############################################################################################################################
|
8 |
# app.py
|
9 |
import os
|
10 |
import re
|
@@ -244,10 +237,10 @@ def main():
|
|
244 |
elif uploaded_file.name.endswith(".txt"):
|
245 |
uploaded_text = uploaded_file.read().decode("utf-8")
|
246 |
|
247 |
-
#
|
248 |
questions = extract_with_llm(uploaded_text)
|
249 |
|
250 |
-
#
|
251 |
def is_meaningful_prompt(text: str) -> bool:
|
252 |
too_short = len(text.strip()) < 10
|
253 |
banned_keywords = ["phone", "email", "fax", "address", "date", "contact", "website"]
|
@@ -257,7 +250,7 @@ def main():
|
|
257 |
|
258 |
filtered_questions = [q for q in questions if is_meaningful_prompt(q)]
|
259 |
|
260 |
-
#
|
261 |
selected_questions = st.multiselect("✅ Choose prompts to answer:", filtered_questions, default=filtered_questions)
|
262 |
|
263 |
if selected_questions:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# app.py
|
2 |
import os
|
3 |
import re
|
|
|
237 |
elif uploaded_file.name.endswith(".txt"):
|
238 |
uploaded_text = uploaded_file.read().decode("utf-8")
|
239 |
|
240 |
+
# extract qs and headers using llms
|
241 |
questions = extract_with_llm(uploaded_text)
|
242 |
|
243 |
+
# filter out irrelevant text
|
244 |
def is_meaningful_prompt(text: str) -> bool:
|
245 |
too_short = len(text.strip()) < 10
|
246 |
banned_keywords = ["phone", "email", "fax", "address", "date", "contact", "website"]
|
|
|
250 |
|
251 |
filtered_questions = [q for q in questions if is_meaningful_prompt(q)]
|
252 |
|
253 |
+
#select prompts to answer
|
254 |
selected_questions = st.multiselect("✅ Choose prompts to answer:", filtered_questions, default=filtered_questions)
|
255 |
|
256 |
if selected_questions:
|