From 06514ab5521675bda650c86beab9f8f78e40744b Mon Sep 17 00:00:00 2001 From: chengxl Date: Thu, 21 Aug 2025 14:49:08 +0800 Subject: [PATCH] =?UTF-8?q?Ai=20=E8=AF=9D=E6=9C=AF=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common/OpenAi.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/application/common/OpenAi.php b/application/common/OpenAi.php index 5f44aff..c7a2037 100644 --- a/application/common/OpenAi.php +++ b/application/common/OpenAi.php @@ -38,7 +38,7 @@ class OpenAi "discussion" => "[针对讨论进行简单总结,采用连贯的段落形式,注意内容不要和文章内容有严重重复,总字数超过450字]", "research_method" => "[针对研究方法进行简单总结,采用连贯的段落形式,注意内容不要和文章内容有严重重复,总字数超过300字]", "discussion" => "[针对讨论进行简单总结,采用连贯的段落形式,注意内容不要和文章内容有严重重复,总字数超过450字]", - "conclusion" => "[针对结论进行简单总结,采用连贯的段落形式,注意内容不要和文章内容有严重重复,总字数超过450字]", + "conclusion" => "[将结论直接翻译成中文,无需针对内容总结翻译]", ], 'review' => [ "overview" => "按照学术规范翻译并提炼文章概述,整体内容应大于1200字,其中应包含文章背景(不少于400字),其他内容提炼更强调逻辑性、科学术语准确性和表达的严谨性,注意内容不要和文章内容有严重重复,采用连贯的段落形式", @@ -749,13 +749,19 @@ class OpenAi if (empty($aMessage)) { return json_encode(['status' => 2, 'msg' => 'AI Q&A content not obtained']); } + + //判断是否执行 + $iIndex = empty($aParam['chunkIndex']) ? 0 : $aParam['chunkIndex']; + $sRedisKey = 'queue_job:ai_create_article:'.$iId; + $sChunkProgress = $this->oQueueRedis->getChunkProgress($sRedisKey, $iIndex); + if(!empty($sChunkProgress)){ + return json_encode(['status' => 3, 'msg' => $sRedisKey.'_'.$iIndex.' Generated']); + } //请求OPENAI $aParam['temperature'] = '0.6'; $aParam['top_p'] = '0.8'; $aResult = $this->curlOpenAIStream($aParam); //更新处理进度 - $iIndex = empty($aParam['chunkIndex']) ? 0 : $aParam['chunkIndex']; - $sRedisKey = 'queue_job:ai_create_article:'.$iId; $sKeyName = empty($aParam['key_name']) ? 'queue_1_completed' : $aParam['key_name']; $iProgress = $this->oQueueRedis->updateQuestionProcessingProgress($sRedisKey,$sKeyName); //保存内容 @@ -1135,14 +1141,19 @@ class OpenAi //问题等级 $sQuestionLevel = empty($aParam['question_level']) ? '' : $aParam['question_level']; + //判断是否执行 + $iIndex = empty($aParam['chunkIndex']) ? 0 : $aParam['chunkIndex']; + $sRedisKey = 'queue_job:review_chunk:'.$iArticleId.'_'.$iJournalId.'_'.$sFieldsName; + $sChunkProgress = $this->oQueueRedis->getChunkProgress($sRedisKey, $iIndex); + if(!empty($sChunkProgress)){ + return json_encode(['status' => 3, 'msg' => $sRedisKey.'_'.$iIndex.' AI Reviewed']); + } //请求OPENAI $aParam['temperature'] = '0.1'; $aParam['top_p'] = '0.9'; $aResult = $this->curlOpenAIStream($aParam); //更新处理进度 - $iIndex = empty($aParam['chunkIndex']) ? 0 : $aParam['chunkIndex']; - $sRedisKey = 'queue_job:review_chunk:'.$iArticleId.'_'.$iJournalId.'_'.$sFieldsName; $sKeyName = empty($aParam['key_name']) ? 'queue_1_completed' : $aParam['key_name']; $iProgress = $this->oQueueRedis->updateQuestionProcessingProgress($sRedisKey,$sKeyName); //保存内容