Davidliu 3 months ago
parent
commit
2e62e6e5f3
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/core/voip/bot.py

+ 4 - 2
src/core/voip/bot.py

@@ -446,10 +446,11 @@ class ToTextBotAgent:
             message = None
             url = f"http://{SERVE_HOST}:40072/botservice"
             headers = {"Content-Type": "application/json"}
+            payload = json.dumps(request_data)
             while try_count > 0:
                 once_start = time.time()
                 try:
-                    response = requests.post(url, data=json.dumps(request_data), headers=headers, timeout=3)
+                    response = requests.post(url, data=payload, headers=headers, timeout=3)
                     if response and response.ok:
                         response_data = response.json()
                         if "data" in response_data and response_data["code"] == 0:
@@ -484,6 +485,7 @@ class ToTextBotAgent:
         response = None
         try:
             url = f"http://{SERVE_HOST}:40072/botservice"
+            payload = json.dumps(request_data)
             # self.call_agent.logger.info(f"请求数据:{request_data},url:{url}")
             with requests.Session() as session:
                 message = None
@@ -493,7 +495,7 @@ class ToTextBotAgent:
                     once_start = time.time()
                     try:
                         try_count = try_count - 1
-                        response = session.post(url=url, json=json.loads(request_data), timeout=3)
+                        response = session.post(url=url, json=payload, timeout=3)
                         # response = requests.post(url=url,  json=json.loads(request_data), headers=headers, timeout=10)  # 使用占位URL
                         self.call_agent.logger.info("to_request come in , try_count=%s", try_count)
                         if response.status_code == 200: