From 1ad6dcf001ed5759c669a62607f5188b6dc85597 Mon Sep 17 00:00:00 2001 From: Yue Fei Date: Tue, 20 Aug 2024 16:06:39 +0800 Subject: [PATCH] Hotfix main branch (#158) * Hotfix * Fix lint * Fix lint --- src/pai_rag/app/web/tabs/chat_tab.py | 9 +++++++-- src/pai_rag/app/web/tabs/upload_tab.py | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/pai_rag/app/web/tabs/chat_tab.py b/src/pai_rag/app/web/tabs/chat_tab.py index 2e0935c5..fd2926be 100644 --- a/src/pai_rag/app/web/tabs/chat_tab.py +++ b/src/pai_rag/app/web/tabs/chat_tab.py @@ -25,12 +25,14 @@ def reset_textbox(): def respond(input_elements: List[Any]): global current_session_id update_dict = {} + for element, value in input_elements.items(): update_dict[element.elem_id] = value # empty input. if not update_dict["question"]: - yield "", update_dict["chatbot"], 0 + yield update_dict["chatbot"] + return try: rag_client.patch_config(update_dict) @@ -61,7 +63,10 @@ def respond(input_elements: List[Any]): raise gr.Error(f"HTTP {api_error.code} Error: {api_error.msg}") content = "" - chatbot.append((msg, content)) + if chatbot is None: + chatbot = [(msg, content)] + else: + chatbot.append((msg, content)) for resp in response_gen: chatbot[-1] = (msg, resp.result) yield chatbot diff --git a/src/pai_rag/app/web/tabs/upload_tab.py b/src/pai_rag/app/web/tabs/upload_tab.py index 1d423c52..7b94c932 100644 --- a/src/pai_rag/app/web/tabs/upload_tab.py +++ b/src/pai_rag/app/web/tabs/upload_tab.py @@ -7,6 +7,8 @@ import pandas as pd import asyncio +IGNORE_FILE_LIST = [".DS_Store"] + def upload_knowledge( upload_files, @@ -46,9 +48,9 @@ def upload_knowledge( ) my_upload_files = [] for file in upload_files: - my_upload_files.append( - MyUploadFile(os.path.basename(file.name), response["task_id"]) - ) + base_name = os.path.basename(file.name) + if base_name not in IGNORE_FILE_LIST: + my_upload_files.append(MyUploadFile(base_name, response["task_id"])) result = {"Info": ["StartTime", "EndTime", "Duration(s)", "Status"]} error_msg = ""