微信公众号相关修改
This commit is contained in:
@@ -65,8 +65,8 @@ class Aiarticle extends Base
|
||||
'Review' => '
|
||||
**核心要求**
|
||||
1️ 内容涵盖哪些学科及方法请罗列
|
||||
2 学术规范翻译并提炼文章概述,更强调逻辑性、科学术语准确性和表达的严谨性,并且不需要分点展示,大于1000字
|
||||
3 针对文章进行简单总结,大于300字
|
||||
2 翻译好的内容将以公众号的形式推送给读者,按学术规范翻译并提炼文章概述,应包函文章背景(不少于200字)内容,其他内容提炼更强调逻辑性、科学术语准确性和表达的严谨性,注意内容不要有严重重复,不需要分点展示,大于1000字
|
||||
3 针对结论简单总结,内容不要重复,大于300字
|
||||
4 请将标题翻译成中文【内容需自然流畅、口语化、连贯性、学术性】
|
||||
{#title_chinese#}
|
||||
5 请将文章内容翻译成中文【内容需自然流畅、口语化、连贯性、学术性】
|
||||
@@ -77,7 +77,7 @@ class Aiarticle extends Base
|
||||
**输出格式**
|
||||
中文格式[英文简写忽略首字母大写]
|
||||
格式内容
|
||||
```json{"covered": "【总字数<=100】", "overview": "【总字数>=1000】", "summary": "【总字数>=350】", "title_chinese": "", "content": ""}'
|
||||
```json{"covered": "【总字数<=100】", "overview": "【总字数>=1000】", "summary": "【总字数>=300】", "title_chinese": "", "content": ""}'
|
||||
];
|
||||
|
||||
//文章图片icon地址
|
||||
@@ -171,7 +171,7 @@ class Aiarticle extends Base
|
||||
* @param aSearch array 模版内容
|
||||
* @param iTemplateId 模版ID
|
||||
*/
|
||||
private function _createContentForOpenAI($aSearch = [],$sArticleType = ''){
|
||||
private function _createContentForOpenAI($aSearch = [],$sArticleType = 'default',$isTranslate = 2){
|
||||
|
||||
if(empty($aSearch) || empty($sArticleType)){
|
||||
return json_encode(array('status' => 2,'msg' => 'Please select a template or enter the content you want to consult'.$this->sError));
|
||||
@@ -182,6 +182,10 @@ class Aiarticle extends Base
|
||||
}else{
|
||||
$sArticleType = 'default';
|
||||
}
|
||||
if($isTranslate == 1){
|
||||
$sArticleType = 1;
|
||||
}
|
||||
|
||||
$sTemplate = $this->aOpenAiAsk[$sArticleType];
|
||||
$sTemplate = str_replace(array_keys($aSearch), array_values($aSearch), $sTemplate);
|
||||
//请求接口
|
||||
@@ -220,8 +224,7 @@ class Aiarticle extends Base
|
||||
* @param model 接口模型
|
||||
* @param stream 是否流式输出 true是false否
|
||||
*/
|
||||
|
||||
public function create(){
|
||||
public function test(){
|
||||
//获取参数
|
||||
$aParam = $this->request->post();
|
||||
$iArticleId = empty($aParam['article_id']) ? '' : $aParam['article_id'];
|
||||
@@ -229,6 +232,16 @@ class Aiarticle extends Base
|
||||
return json_encode(array('status' => 2,'msg' => 'Please select an article' ));
|
||||
}
|
||||
|
||||
//请求OPENAI生成公微内容
|
||||
Queue::push('app\api\job\ArticleAiCreateContent@fire', ['article_id' => $iArticleId], 'ArticleAiCreateContent');
|
||||
}
|
||||
public function create($aParam = []){
|
||||
//获取参数
|
||||
$aParam = empty($aParam) ? $this->request->post() : $aParam;
|
||||
$iArticleId = empty($aParam['article_id']) ? '' : $aParam['article_id'];
|
||||
if(empty($iArticleId)){
|
||||
return json_encode(array('status' => 2,'msg' => 'Please select an article'.json_encode($aParam) ));
|
||||
}
|
||||
//媒体类型
|
||||
$iMediaType = empty($aParam['media_type']) ? 1 : $aParam['media_type'];
|
||||
//获取文章是否生成AI内容
|
||||
@@ -271,14 +284,13 @@ class Aiarticle extends Base
|
||||
if(!empty($aAiArticle['is_generate']) && $aAiArticle['is_generate'] == 1){
|
||||
return json_encode(['status' => 5,'msg' => 'The data has been generated, please proceed with the next steps']);
|
||||
}
|
||||
|
||||
//请求OPENAI
|
||||
$aResult = json_decode($this->createForOpenAi($aArticleContent,$aAiArticle),true);
|
||||
$iStatus = empty($aResult['status']) ? 0 : $aResult['status'];
|
||||
$sMsg = empty($aResult['msg']) ? '生成失败' : $aResult['msg'];
|
||||
if($iStatus == 1){
|
||||
//四小时后推送上传素材并推送草稿箱
|
||||
$iDelaySeconds = 3;//4 * 3600; // 4小时的秒数
|
||||
$iDelaySeconds = 4 * 3600; // 4小时的秒数
|
||||
Queue::later($iDelaySeconds,'app\api\job\WechatMaterial@fire', ['article_id' => $iArticleId], 'WechatMaterial');
|
||||
$sMsg = '文章AI内容生成成功';
|
||||
}else{
|
||||
@@ -945,9 +957,8 @@ class Aiarticle extends Base
|
||||
//请求AI翻译
|
||||
$sContent = '';
|
||||
$aSearch['{#content#}'] = json_encode($aAuthor);
|
||||
$aResult = json_decode($this->_createContentForOpenAI($aSearch,1),true);
|
||||
$aResult = json_decode($this->_createContentForOpenAI($aSearch,1,1),true);
|
||||
$aContent = empty($aResult['data']) ? [] : array_column($aResult['data'], null,'email');
|
||||
|
||||
foreach ($aAuthor as $key => $value) {
|
||||
|
||||
//请求AI翻译
|
||||
@@ -1240,7 +1251,7 @@ class Aiarticle extends Base
|
||||
}
|
||||
|
||||
//写入发布队列
|
||||
// Queue::later(60,'app\api\job\WechatPublishDraft@fire', ['article_id' => $iArticleId], 'WechatPublishDraft');
|
||||
// Queue::later(60,'app\api\job\WechatPublishDraft@fire', ['article_id' => $iArticleId], 'WechatDraftPublish');
|
||||
return json_encode(['status' => 1,'msg' => 'Upload draft box successfully','data' => []]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user