Browse Source

Merge branch '2024-11-25-improve-kimi-response' of Server/title_with_video into 2024-09-23newDbTasks

luojunhui 5 months ago
parent
commit
fa9e2c3d1c
1 changed files with 9 additions and 2 deletions
  1. 9 2
      applications/functions/kimi.py

+ 9 - 2
applications/functions/kimi.py

@@ -205,9 +205,16 @@ class KimiServer(object):
             ],
             model="moonshot-v1-32k",
         )
-        response = chat_completion.choices[0].message.content.replace('```json', '').replace('```', '').replace('“', '"').replace('”', '"')
+        response = chat_completion.choices[0].message.content.replace('```json', '').replace('```', '')
+
         try:
             response = json.loads(response)
             return response
         except:
-            return {}
+            # 处理中文双引号出现在 “key”: “value”情况
+            try:
+                response_json_string = response.replace('“', '"').replace('”', '"')
+                response = json.loads(response_json_string)
+                return response
+            except Exception as e:
+                return {}