fixed
This commit is contained in:
@@ -34,82 +34,86 @@ class Reporttt
|
||||
//header('Cache-Control: no-cache');
|
||||
//header('Connection: keep-alive');
|
||||
//header('X-Accel-Buffering: no');
|
||||
$config = config('ai_num_report_config');
|
||||
return Mmodel::catchJson(function (){
|
||||
$config = config('ai_num_report_config');
|
||||
|
||||
$question = '';//input('question','');
|
||||
$question = '';//input('question','');
|
||||
|
||||
$chatobj = new ChatGPT();
|
||||
$chatobj->url = $config['base_url'];
|
||||
$chatobj->model = '';
|
||||
$chatobj->apiKey = $config['APIKey'];
|
||||
$chatobj = new ChatGPT();
|
||||
$chatobj->url = $config['base_url'];
|
||||
$chatobj->model = '';
|
||||
$chatobj->apiKey = $config['APIKey'];
|
||||
|
||||
$answer_json_arr = [];
|
||||
$answer_json_arr = [];
|
||||
|
||||
$ticket = input('ticket');
|
||||
if(empty($ticket)){
|
||||
$ticket = input('ticket');
|
||||
if(empty($ticket)){
|
||||
|
||||
return json(Tools::set_fail('ticket必须'));
|
||||
}
|
||||
$user = Db::table('fa_tt_users')->where('ticket',$ticket)->find();
|
||||
if(empty($user)){
|
||||
return json(Tools::set_fail('用户不存在'));
|
||||
}
|
||||
|
||||
$day3 = date('Y-m-d 00:00:00',strtotime('-3 day'));
|
||||
$his_record = Db::table('fa_tt_chathistory')
|
||||
//->where('username',$user['username'])
|
||||
->order('id asc')
|
||||
->where('create_time','>',$day3)//3天之内
|
||||
->select();
|
||||
$config = [
|
||||
'stream'=>false,
|
||||
];
|
||||
|
||||
$basedata = [
|
||||
'doctor'=>input('doctor',''),//所属医生
|
||||
'name'=>input('name',''),//病人姓名
|
||||
'gender'=>input('gender',''),//病人性别
|
||||
'age'=>input('age',''),//病人年龄
|
||||
'edu'=>input('edu',''),//教育程度
|
||||
'career_year'=>input('career_year',''),//职业及年限
|
||||
'power'=>input('power',''),//体力要求
|
||||
'satisfaction'=>input('satisfaction',''),//经济满意度
|
||||
'old_career_year'=>input('old_career_year',''),//过往职业及年限
|
||||
'support'=>input('support',''),//社会支持度
|
||||
'marriage'=>input('marriage',''),//婚姻状况
|
||||
'live'=>input('live',''),//居住情况
|
||||
'home'=>input('home',''),//家庭关系
|
||||
'address'=>input('address',''),//地址
|
||||
'phone'=>input('phone',''),//联系方式
|
||||
'wechat_no'=>input('wechat_no',''),//微信号
|
||||
];
|
||||
//只新增不修改
|
||||
Db::table('fa_tt_userbaseinfo')
|
||||
->insert($basedata);
|
||||
|
||||
$content = [
|
||||
//["role" => "user", "content" => '']
|
||||
];
|
||||
foreach ($his_record as $item){
|
||||
$content[] = ["role" => "user", "content" => $item['chat_msg']];
|
||||
}
|
||||
$chatobj->setBefore($content);
|
||||
|
||||
$chatobj->chat($question,$config,$answer_json_arr);
|
||||
//把返回的报告保存起来
|
||||
foreach ($answer_json_arr as $josn){
|
||||
$item = json_decode($josn,true);
|
||||
$choices = $item['choices'];
|
||||
foreach ($choices as $choice){
|
||||
$data = [
|
||||
'doctor'=>$user['username'],
|
||||
//病人
|
||||
'username'=>Db::table('fa_tt_users')->where('doctor',$user['username'])->value('username'),
|
||||
'report_content'=>$choice['message']['content'],
|
||||
];
|
||||
Db::table('fa_tt_medical_report')->insert($data);
|
||||
return Tools::set_fail('ticket必须');
|
||||
}
|
||||
}
|
||||
$user = Db::table('fa_tt_users')->where('ticket',$ticket)->find();
|
||||
if(empty($user)){
|
||||
return Tools::set_fail('用户不存在');
|
||||
}
|
||||
|
||||
//$day3 = date('Y-m-d 00:00:00',strtotime('-3 day'));
|
||||
$his_record = Db::table('fa_tt_chathistory')
|
||||
//->where('username',$user['username'])
|
||||
->order('id asc')
|
||||
//->where('create_time','>',$day3)//3天之内
|
||||
->select();
|
||||
$config = [
|
||||
'stream'=>false,
|
||||
];
|
||||
|
||||
$basedata = [
|
||||
'doctor'=>input('doctor',''),//所属医生
|
||||
'name'=>input('name',''),//病人姓名
|
||||
'gender'=>input('gender',''),//病人性别
|
||||
'age'=>input('age',''),//病人年龄
|
||||
'edu'=>input('edu',''),//教育程度
|
||||
'career_year'=>input('career_year',''),//职业及年限
|
||||
'power'=>input('power',''),//体力要求
|
||||
'satisfaction'=>input('satisfaction',''),//经济满意度
|
||||
'old_career_year'=>input('old_career_year',''),//过往职业及年限
|
||||
'support'=>input('support',''),//社会支持度
|
||||
'marriage'=>input('marriage',''),//婚姻状况
|
||||
'live'=>input('live',''),//居住情况
|
||||
'home'=>input('home',''),//家庭关系
|
||||
'address'=>input('address',''),//地址
|
||||
'phone'=>input('phone',''),//联系方式
|
||||
'wechat_no'=>input('wechat_no',''),//微信号
|
||||
];
|
||||
//只新增不修改
|
||||
Db::table('fa_tt_userbaseinfo')
|
||||
->insert($basedata);
|
||||
|
||||
$content = [
|
||||
//["role" => "user", "content" => '']
|
||||
];
|
||||
foreach ($his_record as $item){
|
||||
$content[] = ["role" => "user", "content" => $item['chat_msg']];
|
||||
}
|
||||
$chatobj->setBefore($content);
|
||||
|
||||
$chatobj->chat($question,$config,$answer_json_arr);
|
||||
//dump($answer_json_arr);die;
|
||||
//把返回的报告保存起来
|
||||
foreach ($answer_json_arr as $josn){
|
||||
$item = json_decode($josn,true);
|
||||
$choices = $item['choices'];
|
||||
foreach ($choices as $choice){
|
||||
$data = [
|
||||
'doctor'=>$user['doctor'],
|
||||
//病人
|
||||
'username'=>$user['username'],
|
||||
'report_content'=>$choice['message']['content'],
|
||||
];
|
||||
Db::table('fa_tt_medical_report')->insert($data);
|
||||
}
|
||||
}
|
||||
return Tools::set_ok('结束');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user