From dbd1d363448f1bebe2380b3f64805b439f7ef008 Mon Sep 17 00:00:00 2001
From: fanpt <320622572@qq.com>
Date: Wed, 6 Mar 2024 16:58:00 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97=E8=BE=93?=
 =?UTF-8?q?=E5=87=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 fast_api.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/fast_api.py b/fast_api.py
index c6b2700..22322d0 100644
--- a/fast_api.py
+++ b/fast_api.py
@@ -78,8 +78,9 @@ def update_kb(kb_name, qa_service, path, max_knowledge_bases):
     save_knowledge_bases(recent_knowledge_bases)
 
     os.remove(path)
-    logger.info(f"Knowledge base updated: {kb_name}")
-    return {"status": "success", "message": "数据库正在更新中"}
+    logger.info(f"Knowledge base updated: {kb_name}\n"
+                f"Please wait while the database is being updated···")
+
 
 def fetch_and_write_data(api_url, path):
     """从API获取数据并写入文件"""
@@ -93,7 +94,6 @@ def fetch_and_write_data(api_url, path):
             with open(path, "w", encoding="utf-8") as file:
                 json.dump(question_items, file, ensure_ascii=False, indent=2)
 
-            logger.info(f"Data fetched and written to file: {path}")
             return True
         else:
             logger.error(f"Failed to fetch data from API. Status code: {response.status_code}, Response data: {response_data}")
@@ -122,8 +122,7 @@ async def save_to_json(question_items: list[QuestionItem], background_tasks: Bac
             update_kb, kb_name, qa_service, path, max_knowledge_bases
         )
 
-        logger.info(f"Data saved to file: {path}, Knowledge base update task scheduled: {kb_name}")
-        return {"status": "success", "message": "数据库正在更新中"}
+        return {"status": "success", "message": "Please wait while the database is being updated···"}
 
     except Exception as e:
         logger.error(f"Error saving data to file or scheduling knowledge base update task: {e}")
@@ -148,7 +147,11 @@ def match_question(request: QuestionRequest):
 
         response = QuestionResponse(code=200, msg="success", data=result)
         stop_time = time.time()
-        logger.info(f"Matched question in {stop_time - start_time} seconds")
+        duration = stop_time - start_time
+
+        logger.info(f"Matched question in {duration} seconds. "
+                    f"Request: {request} - {query}, "
+                    f"Response: {result}")
         return response
 
     except Exception as e: