1
This commit is contained in:
@@ -2,16 +2,19 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\Controller;
|
||||
use app\api\controller\Base;
|
||||
use think\Cache;
|
||||
use think\Db;
|
||||
use think\Queue;
|
||||
use think\Env;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* Description of Auto
|
||||
*
|
||||
* @author jgll2
|
||||
*/
|
||||
class Auto extends Controller
|
||||
class Auto extends Base
|
||||
{
|
||||
|
||||
//put your code here
|
||||
@@ -227,6 +230,150 @@ class Auto extends Controller
|
||||
}
|
||||
|
||||
|
||||
// public function testGpt(){
|
||||
// // die;
|
||||
// $url = "https://api.openai.com/v1/chat/completions";
|
||||
// // $url = "https://api.openai.com/v1/edits";
|
||||
// $data = [];
|
||||
// $data['model'] = "gpt-3.5-turbo";
|
||||
// // $data['model'] = "text-davinci-edit-001";
|
||||
// // $data['input'] = "Homogeneous Time Resolved Fluorescence (HTRF) assay is based on proximity induced fluorescence and can identify candidate compounds that can hinder interaction between hPD-1/hPD-L1 (both proteins need to be tagged). Briefly, this working system is constructed with addition of recombinant proteins, Tag1-PD-L1 and Tag2-PD-1, to 384-well plate. Anti-Tag1-EuK, anti-Tag2-XL665 and diluted solution of small-molecule compounds are added to corresponding wells and incubated at room temperature. Then microplate reader is used to detect the absorbance values at 665 nm and 620 nm at specified time points. The inhibitory ability of the compounds against PD-1/PD-L1 is calculated based on the ratio of readout values of 665nm/620nm at different concentrations.";
|
||||
// // $data['instruction'] = "请帮我按照学术期刊的校对规则 将以下这段文字进行校对 并且同时逐一单独列出来 那些地方被校对了 目标是校对格式 不要改动文本内容 除非确认有拼写或语法错误";
|
||||
// $mes['role'] = "user";
|
||||
// $mes['content'] = "请帮我按照学术期刊的校对规则 将以下这段文字进行校对 并且同时逐一单独列出来 那些地方被校对了 目标是校对格式 不要改动文本内容 除非确认有拼写或语法错误 Background
|
||||
// Parsley is a shiny green biennial medicinal and aromatic herb belonging to the Apiaceae (Umbelliferae) family [1,2]. It is natural to the Mediterranean region (Türkiye, Algeria, Tunisia) and it is now grown in many parts of the world [1].
|
||||
// Moreover to its use as a food among the people, it is used against diseases such as urinary tract infections, menstrual pain, diabetes, hemorrhoids and as a diuretic, kidney stone lowering and blood pressure lowering. In the literature, flavonoids, coumarins, xanthines, vitamins, minerals, and essential oil were reported in P. crispum various parts antioxidant, antibacterial, antifungal, antidiabetic, antihypertensive, The plant had antiplatelet, analgesic, antiinflammatory, antihepatotoxic, antinephrotoxic, anticancer, diuretic, estrogenic and neuroprotective activities.
|
||||
// In this review, the botanical characteristics, ethnobotanical uses, phytochemical composition, pharmacological activities, clinical studies, drug interactions and toxicity of P. crispum are reported. PubMed, Science Direct, Scopus, SciFinder, and Google Scholar databases were used for the search. The search terms used were “Parsley”, “Petroselinum crispum”, “P. crispum”. In addition, some books from related fields were used as reference sources. Data from 1972 to 2022 were collected. All relevant clinical and preclinical studies were selected. The references of the selected articles were also checked to identify possible new research findings.";
|
||||
// $data['messages'] = [$mes];
|
||||
// // $data['prompt'] = "hello chatGpt!";
|
||||
// $data['max_tokens'] = 2048;
|
||||
// // $data['temperature'] = 0.2;
|
||||
// // $data['top_p'] = 1;
|
||||
// // $data['n'] = 1;
|
||||
// $res = postGpt($url,$data);
|
||||
// return jsonSuccess(json_decode($res));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public function GptChar1()
|
||||
{
|
||||
|
||||
// header('Content-Type: text/event-stream'); // 以事件流的形式告知浏览器进行显示
|
||||
// header('Cache-Control: no-cache'); // 告知浏览器不进行缓存
|
||||
// header('X-Accel-Buffering: no');
|
||||
// OpenAI API endpoint
|
||||
$url = 'https://api.openai.com/v1/chat/completions';
|
||||
|
||||
// OpenAI API key
|
||||
$api_key = Env::get("gpt.api_key");
|
||||
|
||||
$mes['role'] = "user";
|
||||
$mes['content'] = "hello";
|
||||
// Request data
|
||||
$data = array(
|
||||
'model' => 'gpt-3.5-turbo',
|
||||
'messages' => [$mes],
|
||||
'temperature' => 0.2,
|
||||
'max_tokens' => 2048,
|
||||
'n' => 1,
|
||||
'stop' => '',
|
||||
'stream' => true // Use streaming mode
|
||||
);
|
||||
|
||||
// Create request headers
|
||||
$headers = array(
|
||||
'Content-Type: application/json',
|
||||
'Authorization: Bearer ' . $api_key
|
||||
);
|
||||
|
||||
// Create context for request
|
||||
$context = stream_context_create(array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => $headers,
|
||||
'content' => json_encode($data),
|
||||
'ignore_errors' => true
|
||||
)
|
||||
));
|
||||
|
||||
// Open connection to API endpoint
|
||||
$fp = fopen($url, 'r', false, $context);
|
||||
// Read response data
|
||||
if ($fp) {
|
||||
while (!feof($fp)) {
|
||||
$chunk = fgets($fp);
|
||||
echo $chunk;
|
||||
// $cache = object_to_array(json_decode(substr($chunk,6)));
|
||||
// if(isset($cache['choices'][0]['delta']['content'])){
|
||||
// $cc = Cache::get("qweqwe")?Cache::get("qweqwe"):'';
|
||||
// Cache::set("qweqwe",$cc.$cache['choices'][0]['delta']['content']);
|
||||
// }
|
||||
// ob_flush();
|
||||
// flush();
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
return "Error: Unable to connect to OpenAI API";
|
||||
}
|
||||
|
||||
|
||||
// Display response data
|
||||
// echo $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建gpt任务
|
||||
*/
|
||||
public function GptCreateChat(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'message'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$d['message'] = $data['message'];
|
||||
$mid = isset($data['mid'])?$data['mid']:"";
|
||||
$d['mid'] = $mid;
|
||||
$ckey = md5(rand(1000,9999).time().$data['message']);
|
||||
$d['ckey'] = $ckey;
|
||||
Queue::push('app\api\job\gpt@fire', $d, "gpt");
|
||||
$re['ckey'] = $ckey;
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动态gpt内容
|
||||
*/
|
||||
public function AjaxForGpt(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'ckey'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$re['msg'] = Cache::get($data['ckey']);
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上下文id
|
||||
*/
|
||||
public function getContentMid(){
|
||||
$data = $this->request->post();
|
||||
$rule = new Validate([
|
||||
'ckey'=>'require'
|
||||
]);
|
||||
if(!$rule->check($data)){
|
||||
return jsonError($rule->getError());
|
||||
}
|
||||
$re['mid'] = Cache::get($data['ckey']."_id");
|
||||
return jsonSuccess($re);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推送邮件提醒作者修回稿件
|
||||
@@ -312,6 +459,19 @@ class Auto extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function ls_addyear()
|
||||
{
|
||||
$num = $this->request->post('num');
|
||||
$url = "http://journalapi.tmrjournals.com/public/index.php/master/Datebase/getaaa";
|
||||
$p['num'] = $num;
|
||||
$res = object_to_array(json_decode(myPost($url, $p)));
|
||||
$list = $res['data']['list'];
|
||||
foreach ($list as $v) {
|
||||
$this->user_author_obj->where('w_article_id', $v['article_id'])->update(['stage_year' => $v['stage_year']]);
|
||||
}
|
||||
return jsonSuccess($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动审稿主方法
|
||||
*/
|
||||
@@ -324,6 +484,7 @@ class Auto extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理过期审稿
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user