root 2 weeks ago
parent
commit
e51c06c3f2
1 changed files with 9 additions and 7 deletions
  1. 9 7
      ai-slibra-assistant/util/request_utils.py

+ 9 - 7
ai-slibra-assistant/util/request_utils.py

@@ -104,7 +104,7 @@ def voice_service(content, local=False, silence_duration="125"):
     encode_b = content.encode("utf-8")
     key = base64.b64encode(encode_b)
     name = "voice_url"
-    retry,num =3,1
+    retry,num = 3,1
     while num <= retry:
         try:
             url = r.hget(name, key)
@@ -119,7 +119,7 @@ def voice_service(content, local=False, silence_duration="125"):
                 return url
         except Exception as e:
             time.sleep(2)
-            logger.info(f"get voice url {num}缓存错误{e}")
+            logger.info(f"get voice url nums {num},缓存错误{e}")
             num +=1
 
 @timetic
@@ -184,7 +184,9 @@ def business_service(session_id, uid, code, tools,  asr):
         return [{"title": "NO", "isFaq": False, "faqContent": '', "asr": asr, "businessContent": ''}]
     # parse water_loc_info
     if tools in ["water_loc_info", "meter_owner_neighbour", "water_info", "meter_owner_phone"]:
-        asr = norm_community(asr)
+        asr2 = norm_community(asr)
+        logger.info(f"tools:{tools}, session:{session_id}, asr:{asr}, norm_asr:{asr2}")
+        asr = asr2
     if tools in ["water_info", "meter_owner_phone"]:
         newtools = "water_loc_info" if tools == "water_info" else "meter_owner_neighbour"
         param = json.dumps(dict(nodeId=code,
@@ -200,14 +202,14 @@ def business_service(session_id, uid, code, tools,  asr):
                                 headers={'Content-Type': 'application/json;charset=utf-8'},
                                 timeout=30)
             resp = json.loads(res.text)
-            logger.info(f"bussiness:{resp}, tools:{tools}, session:{session_id}")
+            logger.info(f"bussiness:{resp}, tools:{tools}, session:{session_id}, asr:{asr}")
             if resp['code'] == "0":
                 content = resp['data'].get("contents")
                 title = "NO" if content is None or len(content) == 0 else "YES"
                 businessContent = getContent(content, tools) if title == "YES" else ''
                 opt = [
                     {"title": title, "isFaq": False, "faqContent": '', "asr": asr, "businessContent": businessContent}]
-                logger.info(f"code:{code},uid:{uid}, tools:{tools},asr:{asr}, opt:{opt}")
+                logger.info(f"session:{session_id},code:{code},uid:{uid}, tools:{tools},asr:{asr}, opt:{opt}")
                 return opt
         except Exception as e:
             logger.info(f"bussion service服务异常:session:{session_id}, tools:{tools},uid:{uid}:{e}")
@@ -224,13 +226,13 @@ def business_service(session_id, uid, code, tools,  asr):
                             headers={'Content-Type': 'application/json;charset=utf-8'},
                             timeout=30)
         resp = json.loads(res.text)
-        logger.info(f"bussiness:{resp}, tools:{tools}, session:{session_id}")
+        logger.info(f"bussiness:{resp}, tools:{tools}, session:{session_id},asr:{asr}")
         if resp['code'] == "0":
             content = resp['data'].get("contents")
             title = "NO" if content is None or len(content)==0  else "YES"
             businessContent = getContent(content, tools) if title == "YES" else ''
             opt = [{"title": title, "isFaq": False, "faqContent": '', "asr": asr, "businessContent": businessContent}]
-            logger.info(f"code:{code},uid:{uid}, tools:{tools},asr:{asr}, opt:{opt}")
+            logger.info(f"session:{session_id},code:{code},uid:{uid}, tools:{tools},asr:{asr}, opt:{opt}")
             return opt
         else:
             return [{"title": "NO", "isFaq": False, "faqContent": '', "asr": asr, "businessContent": ''}]