Jelajahi Sumber

Fix last commit: changes of api_server

StrayWarrior 2 hari lalu
induk
melakukan
d95ef1aa24
1 mengubah file dengan 24 tambahan dan 5 penghapusan
  1. 24 5
      pqai_agent_server/api_server.py

+ 24 - 5
pqai_agent_server/api_server.py

@@ -22,7 +22,8 @@ from pqai_agent.utils.db_utils import create_ai_agent_db_engine
 from pqai_agent.utils.prompt_utils import format_agent_profile, format_user_profile
 from pqai_agent_server.const import AgentApiConst
 from pqai_agent_server.models import MySQLSessionManager
-from pqai_agent_server.utils import wrap_response, quit_human_intervention_status
+import pqai_agent_server.utils
+from pqai_agent_server.utils import wrap_response
 from pqai_agent_server.utils import (
     run_extractor_prompt,
     run_chat_prompt,
@@ -297,8 +298,8 @@ def send_message():
     return wrap_response(200, msg="暂不实现功能")
 
 
-@app.route("/api/quitHumanInterventionStatus", methods=["POST"])
-def quit_human_interventions_status():
+@app.route("/api/quitHumanIntervention", methods=["POST"])
+def quit_human_intervention():
     """
     退出人工介入状态
     :return:
@@ -308,9 +309,27 @@ def quit_human_interventions_status():
     user_id = req_data["user_id"]
     if not user_id or not staff_id:
         return wrap_response(404, msg="user_id and staff_id are required")
-    response = quit_human_intervention_status(user_id, staff_id)
+    if pqai_agent_server.utils.common.quit_human_intervention(user_id, staff_id):
+        return wrap_response(200, msg="success")
+    else:
+        return wrap_response(500, msg="error")
 
-    return wrap_response(200, data=response)
+
+@app.route("/api/enterHumanIntervention", methods=["POST"])
+def enter_human_intervention():
+    """
+    进入人工介入状态
+    :return:
+    """
+    req_data = request.json
+    staff_id = req_data["staff_id"]
+    user_id = req_data["user_id"]
+    if not user_id or not staff_id:
+        return wrap_response(404, msg="user_id and staff_id are required")
+    if pqai_agent_server.utils.common.enter_human_intervention(user_id, staff_id):
+        return wrap_response(200, msg="success")
+    else:
+        return wrap_response(500, msg="error")
 
 ## Agent管理接口
 @app.route("/api/getNativeAgentList", methods=["GET"])