1
This commit is contained in:
@@ -120,10 +120,10 @@ class Production extends Base
|
|||||||
if(!$rule->check($data)){
|
if(!$rule->check($data)){
|
||||||
return jsonError($rule->getError());
|
return jsonError($rule->getError());
|
||||||
}
|
}
|
||||||
|
$p_info = $this->production_article_obj->where('p_article_id',$data['p_article_id'])->find();
|
||||||
$mains = $this->production_article_main_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select();
|
$mains = $this->production_article_main_obj->where('p_article_id',$data['p_article_id'])->where('state',0)->select();
|
||||||
$re['mains'] = $mains;
|
$re['mains'] = $mains;
|
||||||
|
$re['production'] = $p_info;
|
||||||
return jsonSuccess($re);
|
return jsonSuccess($re);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +163,28 @@ class Production extends Base
|
|||||||
return jsonSuccess([]);
|
return jsonSuccess([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**main内容gpt程序校对
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function mainGptcheck(){
|
||||||
|
$data = $this->request->post();
|
||||||
|
$rule = new Validate([
|
||||||
|
'p_main_id'=>'require'
|
||||||
|
]);
|
||||||
|
if(!$rule->check($data)){
|
||||||
|
return jsonError($rule->getError());
|
||||||
|
}
|
||||||
|
$main_info = $this->production_article_main_obj->where('p_main_id',$data['p_main_id'])->find();
|
||||||
|
if(mb_strlen($main_info['content'])<20){
|
||||||
|
return trim($main_info['content']);
|
||||||
|
}
|
||||||
|
$res = object_to_array(json_decode(pushGpt('请将以下内容按照医学期刊的标准校对,不要改变原意,主要是对格式和拼写的校对,将<b></b><i></i>这四个标签保留,将校对好的内容返回 :'.trim($main_info['content']))));
|
||||||
|
$r = $res['choices'][0]['message']['content'];
|
||||||
|
$re['content'] = $r;
|
||||||
|
return jsonSuccess($re);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除生产实例
|
* 删除生产实例
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -334,14 +334,19 @@ function freshContent($production_obj){
|
|||||||
|
|
||||||
function pushGpt($content){
|
function pushGpt($content){
|
||||||
// die;
|
// die;
|
||||||
$url = 'https://api.openai.com/v1/edits';
|
$url = 'https://api.openai.com/v1/chat/completions';
|
||||||
$api_key = Env::get("gpt.api_key");
|
$api_key = Env::get("gpt.api_key");
|
||||||
|
// Request data
|
||||||
|
$mes['role'] = "user";
|
||||||
$mes['content'] = $content;
|
$mes['content'] = $content;
|
||||||
$data = array(
|
$data = array(
|
||||||
'model' => 'text-davinci-edit-001',
|
'model' => 'gpt-3.5-turbo',
|
||||||
'input' => $content,
|
'messages' => [$mes],
|
||||||
'instruction'=>"改正拼写错误;改正时态错误;改正书写格式错误;"
|
'temperature' => 0.2,
|
||||||
);
|
'max_tokens' => 2048,
|
||||||
|
'n' => 1,
|
||||||
|
'stop' => ''
|
||||||
|
);
|
||||||
|
|
||||||
$headers = array(
|
$headers = array(
|
||||||
'Content-Type: application/json',
|
'Content-Type: application/json',
|
||||||
|
|||||||
Reference in New Issue
Block a user