diff --git a/examples/pipelines/slides_ai_search/ui/ui.py b/examples/pipelines/slides_ai_search/ui/ui.py index 418d4b9..7526d32 100644 --- a/examples/pipelines/slides_ai_search/ui/ui.py +++ b/examples/pipelines/slides_ai_search/ui/ui.py @@ -12,10 +12,7 @@ from dotenv import load_dotenv from pathway.xpacks.llm.question_answering import RAGClient -try: - load_dotenv() -except Exception: - pass +load_dotenv() PATHWAY_HOST = os.environ.get("PATHWAY_HOST", "app") PATHWAY_PORT = os.environ.get("PATHWAY_PORT", 8000) @@ -81,7 +78,7 @@ ) -question = st.text_input(label="", placeholder="Why buy") +question = st.text_input(label="", placeholder="What are you searching for?") def get_options_list(metadata_list: list[dict], opt_key: str) -> list: @@ -93,7 +90,7 @@ def get_options_list(metadata_list: list[dict], opt_key: str) -> list: def parse_slide_id_components(slide_id: str) -> tuple[str, int, int]: stem = PurePosixPath(slide_id).stem (name_page, _, page_count) = stem.rpartition("_") - (name, _, page) = stem.rpartition("_") + (name, _, page) = name_page.rpartition("_") return (name, int(page), int(page_count)) @@ -149,10 +146,10 @@ def get_slide_link(file_name, page_num=None) -> str: return image_url -def get_all_drive_files() -> list[str]: - logger.info("request get_all_drive_files") - response = requests.get(file_server_pdf_base_url) - logger.info("response get_all_drive_files") +def get_all_index_files() -> list[str]: + logger.info("request get_all_index_files") + response = requests.get(file_server_pdf_base_url + "/") + logger.info("response get_all_index_files") if response.status_code == 200: soup = BeautifulSoup(response.content, "html.parser") @@ -183,7 +180,7 @@ def get_all_drive_files() -> list[str]: markdown_table += f"| [{file_name}]({link}) |\n" st.markdown(markdown_table, unsafe_allow_html=True) - all_drive_files = get_all_drive_files() + all_drive_files = get_all_index_files() all_drive_files = [urllib.parse.unquote(i) for i in all_drive_files] all_drive_files = [ i for i in all_drive_files if i.endswith(".pdf") or i.endswith(".pptx") @@ -250,20 +247,12 @@ def get_all_drive_files() -> list[str]: def get_category_filter(category: str) -> str: - return f"contains({str(category)}, category)" - if category == "No Filter": - return None - else: - return f"category == `{category}`" + return f"contains(`{str(category)}`, category)" # TODO: merge these def get_language_filter(lang: str) -> str: - return f"contains({str(lang)}, language)" - if lang == "No Filter": - return None - else: - return f"language == `{lang}`" + return f"contains(`{str(lang)}`, language)" def combine_filters(*args: str | None) -> str: @@ -271,16 +260,6 @@ def combine_filters(*args: str | None) -> str: return " && ".join([arg for arg in args if arg is not None]) -@st.cache_resource() -def get_b64img_with_href(bin_str, target_url, width: int = 350, margin=20): - html_code = f"""""" # noqa: E501 - return html_code - - -icon_thumbs_up = '' # noqa: E501 - -icon_thumbs_down = '' # noqa: E501 - css = """