This commit is contained in:
王金磊
2023-05-04 13:41:50 +08:00
parent 883c9a870c
commit 177d1c939f
8 changed files with 398 additions and 20 deletions

View File

@@ -322,6 +322,51 @@ function GptChar($message,$ckey)
}
function freshContent($production_obj){
$production_article_main_obj = Db::name('production_article_main');
$gpt_res =object_to_array(json_decode(pushGpt("请帮我按照学术期刊的校对规则 将以下这段文字进行校对 目标是校对格式 不要改动文本内容 除非确认有拼写或语法错误 ,并且不要去掉<i></i><b></b>这四个标签 直接改在原文:".$production_obj['content']))) ;
$production_article_main_obj->where('p_main_id',$production_obj['p_main_id'])->update(['content_g'=>$gpt_res['choices'][0]['message']['content']]);
$production_article_main_obj->close();
}
function pushGpt($content){
// die;
$url = 'https://api.openai.com/v1/edits';
$api_key = Env::get("gpt.api_key");
$mes['content'] = $content;
$data = array(
'model' => 'text-davinci-edit-001',
'input' => $content,
'instruction'=>"改正拼写错误;改正时态错误;改正书写格式错误;"
);
$headers = array(
'Content-Type: application/json',
'Authorization: Bearer '.$api_key
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if(curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
return $result;
}
/**
* GET 请求
* @param string $url
@@ -536,6 +581,37 @@ function getReviewerCvs($reviewer_id){
return $cvs;
}
function aliemail($email,$title,$content){
// file_put_contents('/usr/a.txt', $email,FILE_APPEND);
vendor('aliemail.email');
$mailto=$email;
$mailsubject=$title;
//组合邮件公共样式
$pre = Env::get('emailtemplete.pre');
$net = Env::get('emailtemplete.net');
$net1 = str_replace("{{email}}",$email,$net);
$mailbody=$pre.$content.$net1;
$smtpserver = "smtpdm-ap-southeast-1.aliyun.com";
$smtpserverport = 80;
$smtpusermail = "propa@hellotmr.top";
// 发件人的账号,填写控制台配置的发信地址,比如xxx@xxx.com
$smtpuser = "propa@hellotmr.top";
// 访问SMTP服务时需要提供的密码(在控制台选择发信地址进行设置)
$smtppass = "Wu751019Pnx";
$mailsubject = "=?UTF-8?B?" . base64_encode($mailsubject) . "?=";
$mailtype = "HTML";
//可选,设置回信地址
$smtpreplyto = "tmr@tmrjournals.com";
$smtp = new \smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass);
$smtp->debug = false;
$cc ="";
$bcc = "";
$additional_headers = "";
//设置发件人名称,名称用户可以自定义填写。
$sender = $title;
$res = $smtp->sendmail($mailto,$smtpusermail, $mailsubject, $mailbody, $mailtype, $cc, $bcc, $additional_headers, $sender, $smtpreplyto);
return $res;
}
/**
* 增加usermsg