|
|
@@ -639,7 +639,8 @@ class robot{
|
|
|
common::echo_json_encode(200,$return);
|
|
|
exit();
|
|
|
} catch (Exception $e) {
|
|
|
- $return = array("type"=>"markdown","is_fixedAnswer_end"=>true,"data" =>$e->getMessage());
|
|
|
+ error_log("ai_chat_exception: ".$e->getMessage());
|
|
|
+ $return = array("type"=>"markdown","is_fixedAnswer_end"=>true,"data" =>"Invalid response");
|
|
|
common::echo_json_encode(200,$return);
|
|
|
exit();
|
|
|
}
|
|
|
@@ -902,7 +903,26 @@ class robot{
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * JSON_ERROR_NONE 0 没有错误
|
|
|
+ * JSON_ERROR_DEPTH 1 超出最大堆栈深度
|
|
|
+ * JSON_ERROR_STATE_MISMATCH 2 JSON 格式不一致或无效
|
|
|
+ * JSON_ERROR_CTRL_CHAR 3 控制字符错误,可能编码不对
|
|
|
+ * JSON_ERROR_SYNTAX 4 语法错误(如缺失括号、逗号等)
|
|
|
+ * JSON_ERROR_UTF8 5 编码错误,非 UTF-8 字符
|
|
|
+ * JSON_ERROR_RECURSION 6 检测到递归引用
|
|
|
+ * JSON_ERROR_INF_OR_NAN 7 不能编码 INF 或 NAN
|
|
|
+ * JSON_ERROR_UNSUPPORTED_TYPE 8 不支持的数据类型
|
|
|
+ */
|
|
|
$message = json_decode(common::getChatAimessage($response['message']),true);
|
|
|
+ if ($message === null) {
|
|
|
+ // 获取最后一次 JSON 操作的错误码
|
|
|
+ $errorCode = json_last_error();
|
|
|
+ // 获取错误描述(PHP 5.5+)
|
|
|
+ $errorMsg = json_last_error_msg();
|
|
|
+ error_log("AI Message JSON Decode Error : {$errorCode} - {$errorMsg}");
|
|
|
+ }
|
|
|
+
|
|
|
if($message["can_query"] == "true" && !empty($message["sql"])){
|
|
|
$reference = $message["reference"];
|
|
|
$answer_template = common::check_input($message["reference"]);
|
|
|
@@ -942,7 +962,7 @@ class robot{
|
|
|
}else{
|
|
|
$answer = $message["response"];
|
|
|
if(!$response['success']){
|
|
|
- $answer = $response["error"];
|
|
|
+ $answer = "Invalid response";
|
|
|
}
|
|
|
}
|
|
|
|