fixed
This commit is contained in:
@@ -40,7 +40,6 @@ class TychatLogic extends BaseLogic
|
||||
$json = Tools::wss_json_fail($action, 'items参数错误');
|
||||
return Gateway::sendToClient($client_id, $json);
|
||||
}
|
||||
$obj = new TychatLogic();
|
||||
if(empty($data['items']['chat_msg'])){
|
||||
$json = Tools::wss_json($action, 550,'chat_msg参数错误');
|
||||
return Gateway::sendToClient($client_id, $json);
|
||||
@@ -67,7 +66,7 @@ class TychatLogic extends BaseLogic
|
||||
}
|
||||
$username = $user['username'];
|
||||
//保存记录
|
||||
$obj->saveHistory($username,$chat_msg,$type);
|
||||
$this->saveHistory($username,$chat_msg,$type);
|
||||
|
||||
//广播消息
|
||||
//查询广播客户端id
|
||||
@@ -80,8 +79,8 @@ class TychatLogic extends BaseLogic
|
||||
$json = Tools::wss_json_ok($action, $chat_msg);
|
||||
Gateway::sendToAll($json, $clientid_arr);
|
||||
|
||||
//健康小洞察
|
||||
$this->getHealthInsight($clientid_arr,$chat_msg);
|
||||
////健康小洞察
|
||||
//$this->getHealthInsight($clientid_arr,$chat_msg);
|
||||
});
|
||||
}
|
||||
/**
|
||||
@@ -121,7 +120,7 @@ class TychatLogic extends BaseLogic
|
||||
|
||||
/**
|
||||
* desc:健康洞察
|
||||
*
|
||||
* 请求类型:wss
|
||||
* action: HealthInsights/getHealthInsight
|
||||
* items:[
|
||||
* 'content'=>[
|
||||
@@ -130,9 +129,33 @@ class TychatLogic extends BaseLogic
|
||||
* ]
|
||||
* author:wh
|
||||
*/
|
||||
private function getHealthInsight($clientid_arr,$chat_msg){
|
||||
function getHealthInsight($client_id,$data){
|
||||
Tools::log_to_write_txt(['健康洞察,入参'=>['域名'=>request()->controller().'/'.request()->action()]]);
|
||||
$action = 'Tychat/getHealthInsight';
|
||||
if(empty($data['items'])){
|
||||
$json = Tools::wss_json_fail($action, 'items参数错误');
|
||||
return Gateway::sendToClient($client_id, $json);
|
||||
}
|
||||
if(empty($data['items']['content'])){
|
||||
$json = Tools::wss_json_fail($action, 'content参数必须');
|
||||
return Gateway::sendToClient($client_id, $json);
|
||||
}
|
||||
$content = json_decode($data['items']['content'],true);
|
||||
if(empty($data['items']['username'])){
|
||||
$json = Tools::wss_json_fail($action, 'username参数必须');
|
||||
return Gateway::sendToClient($client_id, $json);
|
||||
}
|
||||
$username = $data['items']['username'];
|
||||
//广播消息
|
||||
//查询广播客户端id
|
||||
$arr = Db::table('fa_device')
|
||||
->where('username',$username)
|
||||
->where('clientid','neq',$client_id)
|
||||
->select();
|
||||
$clientid_arr = array_column($arr,'clientid');
|
||||
|
||||
|
||||
$config = config('ai_health_insight_config');
|
||||
$action = 'HealthInsights/getHealthInsight';
|
||||
$question = '';//input('question','');
|
||||
//$content = [
|
||||
// ["role" => "user", "content" => '']
|
||||
@@ -147,19 +170,6 @@ class TychatLogic extends BaseLogic
|
||||
$config = [
|
||||
'stream'=>false,
|
||||
];
|
||||
//$content = [
|
||||
// ["role" => "user", "content" => $chat_msg]
|
||||
//];
|
||||
//if(empty($data['items']['content'])){
|
||||
// $json = Tools::wss_json_fail($action, 'content参数必须');
|
||||
// return Gateway::sendToAll($json, $client_id);
|
||||
//}
|
||||
$content = [
|
||||
["role" => "user", "content" => $chat_msg]
|
||||
];
|
||||
//foreach ($his_record as $item){
|
||||
// $content[] = ["role" => "user", "content" => $item['chat_msg']];
|
||||
//}
|
||||
$chatobj->setBefore($content);
|
||||
|
||||
$chatobj->returnAnswer($question,$config,$answer_json_arr);
|
||||
|
||||
Reference in New Issue
Block a user