公共方法
This commit is contained in:
@@ -9,7 +9,8 @@ class Article
|
||||
protected $sJavaUrl = "http://ts.tmrjournals.com/";
|
||||
//官网文件地址
|
||||
protected $sFileUrl = "https://submission.tmrjournals.com/public/";
|
||||
|
||||
//Ai地址
|
||||
protected $sAiUrl = "http://125.39.141.154:10002";
|
||||
/**
|
||||
* 获取文章文件内容
|
||||
*/
|
||||
@@ -58,21 +59,28 @@ class Article
|
||||
public function updateAiArticle($aParam = []){
|
||||
//文章ID
|
||||
$iArticleId = empty($aParam['article_id']) ? 0 : $aParam['article_id'];
|
||||
//主键ID
|
||||
$iAiArticleId = empty($aParam['ai_article_id']) ? 0 : $aParam['ai_article_id'];
|
||||
|
||||
//查询内容是否存在
|
||||
$aWhere = ['is_delete' => 2];
|
||||
if(empty($iArticleId)){
|
||||
if(empty($iArticleId) && empty($iArticleId)){
|
||||
return json_encode(['status' => 2,'msg' => 'Please select the article to be modified']);
|
||||
}
|
||||
|
||||
if(!empty($iArticleId)){
|
||||
$aWhere['article_id'] = $iArticleId;
|
||||
}
|
||||
if(!empty($iAiArticleId)){
|
||||
$aWhere['ai_article_id'] = $iAiArticleId;
|
||||
}
|
||||
//查询文章是否生成AI内容
|
||||
$aWhere= ['is_delete' => 2,'article_id' => $iArticleId];
|
||||
$aAiArticle = Db::name('ai_article')->field('ai_article_id')->where($aWhere)->find();
|
||||
if(empty($aAiArticle)){
|
||||
return json_encode(['status' => 3,'msg' => 'The article content of WeChat official account has not been generated']);
|
||||
}
|
||||
$iAiArticleId = $aAiArticle['ai_article_id'];
|
||||
//必填参数验证
|
||||
$aFields = ['article_id','title_english','title_chinese','journal_issn','covered','digest','research_result','content','highlights','discussion','prospect','research_background','discussion_results','research_method','overview','summary','is_generate'];
|
||||
$aFields = ['article_id','article_type','media_type','journal_id','journal_issn','title_english','title_chinese','content','covered','discussion_results','research_method','digest','research_background','overview','summary','highlights','discussion','prospect','is_generate'];
|
||||
$sFiled = '';
|
||||
$aUpdateParam = [];
|
||||
foreach($aFields as $val){
|
||||
@@ -147,9 +155,9 @@ class Article
|
||||
|
||||
//获取文章领域
|
||||
$aArticleField = $this->getArticleField($aWhere);
|
||||
if(!empty($aArticleField['data'])){
|
||||
return json_encode(array('status' => 4,'msg' =>'The article has been added to the field' ));
|
||||
}
|
||||
// if(!empty($aArticleField['data'])){
|
||||
// return json_encode(array('status' => 4,'msg' =>'The article has been added to the field' ));
|
||||
// }
|
||||
//文章标题
|
||||
$title = empty($aArticle['title']) ? '' : $aArticle['title'];
|
||||
if(empty($title)){
|
||||
@@ -187,7 +195,7 @@ class Article
|
||||
|
||||
//请求OPENAI
|
||||
$oOpenAi = new OpenAi;
|
||||
$aParam = ['messages' => $aMessage,'model' => empty($aParam['api_model']) ? 'gpt-4.1' : $aParam['api_model']];
|
||||
$aParam = ['messages' => $aMessage,'model' => empty($aParam['api_model']) ? 'gpt-4.1' : $aParam['api_model'],'url' => $this->sAiUrl];
|
||||
$aResult = json_decode($oOpenAi->curlOpenAIStream($aParam),true);
|
||||
//处理返回信息
|
||||
$aData = empty($aResult['data']) ? [] : $aResult['data'];
|
||||
|
||||
Reference in New Issue
Block a user