chore(addon/aikefu): 更新文档说明及功能
This commit is contained in:
@@ -35,6 +35,14 @@ class AI extends BaseApi
|
||||
'check_type' => $this->params['check_type'] ?? 'full' // full, basic, ai_service
|
||||
];
|
||||
|
||||
$health_summary = null;
|
||||
$event_data = [
|
||||
'check_id' => uniqid('health_', true),
|
||||
'timestamp' => date('Y-m-d H:i:s'),
|
||||
'site_id' => $site_id,
|
||||
'check_type' => $this->params['check_type'] ?? 'full' // full, basic, ai_service
|
||||
];
|
||||
|
||||
try {
|
||||
// 触发健康检查事件
|
||||
$result = Event::trigger('KefuHealthCheck', $event_data);
|
||||
@@ -116,8 +124,8 @@ class AI extends BaseApi
|
||||
'message' => '健康检查失败',
|
||||
'data' => [
|
||||
'status' => 'error',
|
||||
'check_id' => $event_data['check_id'],
|
||||
'timestamp' => $event_data['timestamp'],
|
||||
'check_id' => $event_data['check_id'] ?? '',
|
||||
'timestamp' => $event_data['timestamp'] ?? date('Y-m-d H:i:s'),
|
||||
'error' => $e->getMessage(),
|
||||
'response_time_ms' => round((microtime(true) - $start_time) * 1000, 2)
|
||||
]
|
||||
@@ -215,9 +223,9 @@ class AI extends BaseApi
|
||||
$member_id = $this->params['member_id'] ?? $this->member_id;
|
||||
$token = $this->params['token'] ?? $this->token;
|
||||
|
||||
// 验证参数
|
||||
if (empty($conversation_id)) {
|
||||
return $this->response($this->error('会话ID不能为空'));
|
||||
// 验证参数(conversation_id 和 user_id 至少需要一个)
|
||||
if (empty($conversation_id) && empty($user_id)) {
|
||||
return $this->response($this->error('会话ID或用户ID不能为空'));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -254,7 +262,7 @@ class AI extends BaseApi
|
||||
|
||||
return $this->response($response);
|
||||
} catch (\Exception $e) {
|
||||
return $this->response($e->getMessage());
|
||||
return $this->response($this->error('请求失败:' . $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,26 +347,26 @@ class AI extends BaseApi
|
||||
// 验证参数
|
||||
if (empty($message)) {
|
||||
$this->sendStreamError('请输入消息内容');
|
||||
return;
|
||||
exit;
|
||||
}
|
||||
|
||||
// 准备事件数据
|
||||
$event_data = [
|
||||
'message' => $message,
|
||||
'user_id' => $user_id,
|
||||
'conversation_id' => $conversation_id,
|
||||
'stream' => $stream,
|
||||
'site_id' =>$site_id,
|
||||
'member_id' => $member_id,
|
||||
'token' => $token,
|
||||
'request_id' => uniqid('stream_', true),
|
||||
'timestamp' => time(),
|
||||
];
|
||||
|
||||
try {
|
||||
// 设置流式响应头
|
||||
$this->setStreamHeaders();
|
||||
|
||||
// 准备事件数据
|
||||
$event_data = [
|
||||
'message' => $message,
|
||||
'user_id' => $user_id,
|
||||
'conversation_id' => $conversation_id,
|
||||
'stream' => $stream,
|
||||
'site_id' =>$site_id,
|
||||
'member_id' => $member_id,
|
||||
'token' => $token,
|
||||
'request_id' => uniqid('stream_', true),
|
||||
'timestamp' => time(),
|
||||
];
|
||||
|
||||
// 发送开始事件
|
||||
$this->sendStreamEvent('start', [
|
||||
'request_id' => $event_data['request_id'],
|
||||
@@ -560,9 +568,9 @@ class AI extends BaseApi
|
||||
$member_id = $this->params['member_id'] ?? $this->member_id;
|
||||
$token = $this->params['token'] ?? $this->token;
|
||||
|
||||
// 验证参数
|
||||
if (empty($conversation_id)) {
|
||||
return $this->response($this->error('会话ID不能为空'));
|
||||
// 验证参数(conversation_id 和 user_id 至少需要一个)
|
||||
if (empty($conversation_id) && empty($user_id)) {
|
||||
return $this->response($this->error('会话ID或用户ID不能为空'));
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user