fixed
This commit is contained in:
@@ -10,6 +10,7 @@ namespace app\api\controller;
|
||||
|
||||
|
||||
use think\Db;
|
||||
use wanghua\general_utility_tools_php\gpt\chat\ChatGPT;
|
||||
use wanghua\general_utility_tools_php\Mmodel;
|
||||
use wanghua\general_utility_tools_php\tool\Tools;
|
||||
|
||||
@@ -44,6 +45,12 @@ class Feedback extends BaseHttpApi
|
||||
return Tools::set_fail('群id不能为空');
|
||||
}
|
||||
|
||||
//得到3条反馈消息,AI去总结
|
||||
$str = $this->aiResult($content);
|
||||
if(empty($str)){
|
||||
$str = $content;
|
||||
}
|
||||
|
||||
//查询是否有回访记录
|
||||
$ret = Db::table('fa_firmcustomerfollowuprecord')
|
||||
->where('wx_groupid',$wx_groupid)
|
||||
@@ -58,11 +65,31 @@ class Feedback extends BaseHttpApi
|
||||
'firmcustomer_id'=>$ret['firmcustomer_id'],
|
||||
'rel_wx'=>$ret['rel_wx'],
|
||||
'rel_group'=>$ret['rel_group'],
|
||||
'msg'=>$content,
|
||||
'msg'=>$str,
|
||||
'firmcustomerfollowuprecord_id'=>$ret['id'],
|
||||
])
|
||||
->insert();
|
||||
return Tools::set_ok();
|
||||
});
|
||||
}
|
||||
|
||||
//ai总结反馈消息
|
||||
private function aiResult(string $msg){
|
||||
$ai_config = config('ai_config.follow_result');
|
||||
//反馈消息,AI去总结
|
||||
$chat_obj = new ChatGPT();
|
||||
$chat_obj->url = $ai_config['base_url'];
|
||||
$chat_obj->apiKey = $ai_config['api_key'];
|
||||
Tools::log_to_write_txt(['ai总结反馈消息,开始:'=>$msg]);
|
||||
$res = $chat_obj->getchatgptresponse($msg);
|
||||
Tools::log_to_write_txt(['ai总结反馈消息,结束:'=>$res]);
|
||||
if($res['code'] != 200){
|
||||
return '';
|
||||
}
|
||||
|
||||
$json_arr = json_decode($res['data'],true);
|
||||
Tools::log_to_write_txt(['$json_arr'=>$json_arr]);
|
||||
$str = '';
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user