This commit is contained in:
chengxl
2025-07-17 18:04:51 +08:00
parent c471a5df75
commit 73cbf94a53

View File

@@ -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);