Skip to content

Commit 088dc5f

Browse files
committed
feat: implement export_single_faq_page_to_md utility; enhance logging in ChatApp; add new log tags for NOT-ANSWERED and STREAMLIT
1 parent d600d78 commit 088dc5f

5 files changed

Lines changed: 46 additions & 10 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ WORKDIR /app
77
RUN apt-get update && apt-get install -y \
88
sudo \
99
wget \
10+
vim \
1011
gettext \
1112
&& rm -rf /var/lib/apt/lists/*
1213

data_ingestion/crud_ragflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def insert_metadata_ragflow(
4646
base_url=None,
4747
api_key=None,
4848
):
49-
# TODO: Onls works with md files for now. Extend to other file types.
49+
# TODO: Only works with md files for now. Extend to other file types.
5050
base_url = base_url or settings.vector_db_settings.settings.base_url
5151
api_key = api_key or os.getenv("RAGFLOW_API_KEY")
5252

data_ingestion/detect_faq.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,18 @@ async def run(
313313
logger.info(f"Failed URLs: {failed_urls}")
314314

315315

316+
async def export_single_faq_page_to_md(url: str) -> None:
317+
"""Utility function to export a single FAQ page to Markdown."""
318+
config = FAQDetectorConfig()
319+
detector = FAQDetector(config)
320+
content = await detector.crawl_url(url)
321+
if content and content.markdown:
322+
detector.save_faq_content(content, url)
323+
logger.info(f"Successfully exported FAQ page to Markdown: {url}")
324+
else:
325+
logger.error(f"Failed to crawl or export FAQ page: {url}")
326+
327+
316328
async def main():
317329
"""Main function to run the FAQ detector."""
318330
config = FAQDetectorConfig()
@@ -327,4 +339,5 @@ async def main():
327339

328340

329341
if __name__ == "__main__":
342+
# export_single_faq_page_to_md("url_to_faq_page_here")
330343
asyncio.run(main())

pages/ask_uos_chat.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -451,24 +451,36 @@ def _get_stream():
451451

452452
except GraphRecursionError as e:
453453
# TODO handle recursion limit error
454-
logger.exception(f"[LANGGRAPH] Recursion Limit reached: {e}")
455-
response = session_state["_"](
456-
"I'm sorry, but I couldn't find enough information to fully answer your question. Could you please try rephrasing your query and ask again?"
454+
logger.warning(
455+
f"[NOT-ANSWERED] Recursion Limit reached. Query: {user_input} . Sources used. Documents: {graph._visited_docs()}, Urls: {graph._visited_links}"
456+
)
457+
response = (
458+
session_state["_"](
459+
"I'm sorry, but I couldn't find enough information to fully answer your question. Could you please try rephrasing your query and ask again?"
460+
)
461+
+ f"\n\n{further_help_msg}"
457462
)
458-
st.markdown(f"{response}\n\n{further_help_msg}")
463+
459464
# clear the docs references
465+
st.markdown(response)
460466
graph._visited_docs.clear()
461467

462468
except ProgrammableSearchException as e:
463-
response = session_state["_"](
464-
"I'm sorry, something went wrong while connecting to the data provided. If the error persists, please reach out to the administrators for assistance."
469+
response = (
470+
session_state["_"](
471+
"I'm sorry, something went wrong while connecting to the data provided. If the error persists, please reach out to the administrators for assistance."
472+
)
473+
+ f"\n{further_help_msg}"
465474
)
466-
st.markdown(f"{response}\n{further_help_msg}")
475+
476+
st.markdown(response)
467477
# clear the docs references
468478
graph._visited_docs.clear()
469479

470480
except Exception as e:
471-
logger.exception(f"Error while processing the user's query: {e}")
481+
logger.exception(
482+
f"[STREAMLIT] Error while processing the user's query: {e}"
483+
)
472484
response = session_state["_"](
473485
"I'm sorry, but I am unable to process your request right now. Please try again later or consider rephrasing your question."
474486
)
@@ -484,7 +496,15 @@ def _get_stream():
484496
start_time = time.time()
485497
settings.time_request_sent = start_time
486498

487-
response, to_stream = stream_graph_updates(prompt)
499+
try:
500+
response, to_stream = stream_graph_updates(prompt)
501+
except Exception as e:
502+
logger.error(f"[STREAMLIT] Error in streaming graph updates: {e}")
503+
response = session_state["_"](
504+
"I'm sorry, but I am unable to process your request right now. Please try again later or consider rephrasing your question."
505+
)
506+
to_stream = ""
507+
st.markdown(response)
488508
# if there is content left, stream it
489509
if to_stream:
490510
st.markdown(to_stream)

src/chatbot_log/log_tags.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
- VECTOR DB
2121
- RAGFlow
2222
- EMBEDDING
23+
- NOT-ANSWERED e.g., A recursion error occurs because the content needed to answer the question was not found.
24+
- STREAMLIT
2325

2426

2527
## Example Usage

0 commit comments

Comments
 (0)