fixed
This commit is contained in:
@@ -77,9 +77,9 @@ class TychatLogic extends BaseLogic
|
|||||||
$clientid_arr = array_column($arr,'clientid');
|
$clientid_arr = array_column($arr,'clientid');
|
||||||
|
|
||||||
$json = Tools::wss_json_ok($action, $chat_msg);
|
$json = Tools::wss_json_ok($action, $chat_msg);
|
||||||
Gateway::sendToAll($json);
|
Gateway::sendToAll($json,null,[$client_id]);
|
||||||
|
|
||||||
////健康小洞察
|
//健康小洞察
|
||||||
$this->getHealthInsight2($client_id,$clientid_arr,$chat_msg);
|
$this->getHealthInsight2($client_id,$clientid_arr,$chat_msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ class TychatLogic extends BaseLogic
|
|||||||
/**
|
/**
|
||||||
* desc:健康洞察
|
* desc:健康洞察
|
||||||
* 请求类型:wss
|
* 请求类型:wss
|
||||||
* action: Tychat/getHealthInsight
|
* action: Tychat/getHealthInsight2
|
||||||
* items:[
|
* items:[
|
||||||
* username:'18922226666',
|
* username:'18922226666',
|
||||||
* content=>[
|
* content=>[
|
||||||
@@ -130,60 +130,6 @@ class TychatLogic extends BaseLogic
|
|||||||
* ]
|
* ]
|
||||||
* author:wh
|
* author:wh
|
||||||
*/
|
*/
|
||||||
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();
|
|
||||||
if(empty($arr)){
|
|
||||||
$json = Tools::wss_json_fail($action, '没有找到广播对象,请绑定设备');
|
|
||||||
return Gateway::sendToClient($client_id, $json);
|
|
||||||
}
|
|
||||||
|
|
||||||
$clientid_arr = array_column($arr,'clientid');
|
|
||||||
|
|
||||||
|
|
||||||
$config = config('ai_health_insight_config');
|
|
||||||
$question = '';//input('question','');
|
|
||||||
//$content = [
|
|
||||||
// ["role" => "user", "content" => '']
|
|
||||||
//];
|
|
||||||
$chatobj = new ChatGPT();
|
|
||||||
$chatobj->url = $config['base_url'];
|
|
||||||
$chatobj->model = '';
|
|
||||||
$chatobj->apiKey = $config['APIKey'];
|
|
||||||
|
|
||||||
$answer_json_arr = [];
|
|
||||||
|
|
||||||
$config = [
|
|
||||||
'stream'=>false,
|
|
||||||
];
|
|
||||||
$chatobj->setBefore($content);
|
|
||||||
|
|
||||||
$chatobj->returnAnswer($question,$config,$answer_json_arr);
|
|
||||||
//return json(Tools::set_ok('查询成功',$answer_json_arr));
|
|
||||||
|
|
||||||
$json = Tools::wss_json_ok($action, 'ok',$answer_json_arr);
|
|
||||||
Gateway::sendToAll($json);
|
|
||||||
}
|
|
||||||
function getHealthInsight2($client_id,$clientid_arr,$chat_msg){
|
function getHealthInsight2($client_id,$clientid_arr,$chat_msg){
|
||||||
Tools::log_to_write_txt(['健康洞察,入参'=>['域名'=>request()->controller().'/'.request()->action()]]);
|
Tools::log_to_write_txt(['健康洞察,入参'=>['域名'=>request()->controller().'/'.request()->action()]]);
|
||||||
$action = 'Tychat/getHealthInsight2';
|
$action = 'Tychat/getHealthInsight2';
|
||||||
|
|||||||
Reference in New Issue
Block a user