From 73cbf94a53ea749111b8b0d9d368fd7c40088d99 Mon Sep 17 00:00:00 2001 From: chengxl Date: Thu, 17 Jul 2025 18:04:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/controller/Aiarticle.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/application/api/controller/Aiarticle.php b/application/api/controller/Aiarticle.php index a9dcab1..daffd46 100644 --- a/application/api/controller/Aiarticle.php +++ b/application/api/controller/Aiarticle.php @@ -76,20 +76,30 @@ class Aiarticle extends Base $oOpenAi = new OpenAi; if($sArticleType == 'default'){ $aMessage = $oOpenAi->buildDefaultPrompt($aSearch); + if(empty($aMessage)){ + return json_encode(['status' => 5,'msg' => 'AI Q&A content not obtained']); + } + $aParam = ['messages' => $aMessage,'model' => empty($aParam['api_model']) ? 'gpt-4.1' : $aParam['api_model'],'redis_id' => empty($aSearch['article_id']) ? 0 : $aSearch['article_id']]; + $aResult = json_decode($oOpenAi->createWechatContent($aParam),true); } if($sArticleType == 'Review'){ $aMessage = $oOpenAi->buildReviewPrompt($aSearch); + if(empty($aMessage)){ + return json_encode(['status' => 5,'msg' => 'AI Q&A content not obtained']); + } + $aParam = ['messages' => $aMessage,'model' => empty($aParam['api_model']) ? 'gpt-4.1' : $aParam['api_model'],'redis_id' => empty($aSearch['article_id']) ? 0 : $aSearch['article_id']]; + $aResult = json_decode($oOpenAi->createWechatContent($aParam),true); } if($sArticleType == 1){ $aMessage = $oOpenAi->buildTranslatePrompt($aSearch); - } - if(empty($aMessage)){ - return json_encode(['status' => 5,'msg' => 'AI Q&A content not obtained']); + if(empty($aMessage)){ + return json_encode(['status' => 5,'msg' => 'AI Q&A content not obtained']); + } + $aParam = ['messages' => $aMessage,'model' => empty($aParam['api_model']) ? 'gpt-4.1' : $aParam['api_model']]; + $aResult = json_decode($oOpenAi->curlOpenAI($aParam),true); } //请求OPENAI接口 - $aParam = ['messages' => $aMessage,'model' => empty($aParam['api_model']) ? 'gpt-4.1' : $aParam['api_model'],'redis_id' => $aSearch['article_id']]; - $aResult = json_decode($oOpenAi->createWechatContent($aParam),true); $iStatus = empty($aResult['status']) ? 0 : $aResult['status']; if($iStatus != 1){ return json_encode($aResult);