正在显示
1 个修改的文件
包含
22 行增加
和
5 行删除
| @@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
| 2 | 2 | ||
| 3 | namespace App\Http\Logic\Bside\Ai; | 3 | namespace App\Http\Logic\Bside\Ai; |
| 4 | 4 | ||
| 5 | +use App\Helper\Common; | ||
| 6 | +use App\Helper\Gpt; | ||
| 5 | use App\Helper\Translate; | 7 | use App\Helper\Translate; |
| 6 | use App\Http\Logic\Bside\BaseLogic; | 8 | use App\Http\Logic\Bside\BaseLogic; |
| 7 | use App\Models\Ai\AiBlog; | 9 | use App\Models\Ai\AiBlog; |
| @@ -174,17 +176,32 @@ class AiBlogLogic extends BaseLogic | @@ -174,17 +176,32 @@ class AiBlogLogic extends BaseLogic | ||
| 174 | $param['route'] = generateRoute(Translate::tran($param['route'] ?? $param['new_title'], 'en')); | 176 | $param['route'] = generateRoute(Translate::tran($param['route'] ?? $param['new_title'], 'en')); |
| 175 | //推送到ai的数据结构 | 177 | //推送到ai的数据结构 |
| 176 | $data = [ | 178 | $data = [ |
| 177 | - 'title'=>$param['new_title'], 'thumb'=>$param['image'], 'foreword'=>$param['description'], | 179 | + 'title'=>$param['new_title'], 'thumb'=>$param['image'], 'foreword'=>$param['description'] ?? '', |
| 178 | 'author_id'=>$this->param['author_id'], 'url'=>$param['route'], | 180 | 'author_id'=>$this->param['author_id'], 'url'=>$param['route'], |
| 179 | ]; | 181 | ]; |
| 180 | if(isset($param['id']) && !empty($param['id'])){ | 182 | if(isset($param['id']) && !empty($param['id'])){ |
| 181 | $id = $param['id']; | 183 | $id = $param['id']; |
| 182 | $data['task_id'] = $param['task_id']; | 184 | $data['task_id'] = $param['task_id']; |
| 183 | - if(empty($param['seo_keyword'])){ | 185 | + if(!isset($param['seo_keyword']) || empty($param['seo_keyword'])){ |
| 184 | $ai = "contains keyword {$param['title']} recommend 8 purchaser search keywords, separated by commas"; | 186 | $ai = "contains keyword {$param['title']} recommend 8 purchaser search keywords, separated by commas"; |
| 185 | - } | ||
| 186 | - if(empty($param['seo_description'])){ | ||
| 187 | - $ai = "According to the keyword {keyword}, write a seo meta description show to purchaser within 200 characters"; | 187 | + $text = Gpt::instance()->openai_chat_qqs($ai); |
| 188 | + $text = Common::deal_keywords($text); | ||
| 189 | + $text = Common::deal_str($text); | ||
| 190 | + $param['seo_keyword'] = $text; | ||
| 191 | + } | ||
| 192 | + if(!isset($param['seo_description']) && empty($param['seo_description'])){ | ||
| 193 | + $ai = "According to the keyword {$param['title']}, write a seo meta description show to purchaser within 200 characters"; | ||
| 194 | + $text1 = Gpt::instance()->openai_chat_qqs($ai); | ||
| 195 | + $text1 = Common::deal_keywords($text1); | ||
| 196 | + $text1 = Common::deal_str($text1); | ||
| 197 | + $param['seo_keyword'] = $text1; | ||
| 198 | + } | ||
| 199 | + if(!isset($param['description']) || empty($param['description'])){ | ||
| 200 | + $ai = "According to the keyword {$param['title']}, write a seo meta description show to purchaser within 100 characters"; | ||
| 201 | + $text2 = Gpt::instance()->openai_chat_qqs($ai); | ||
| 202 | + $text2 = Common::deal_keywords($text2); | ||
| 203 | + $text2 = Common::deal_str($text2); | ||
| 204 | + $param['description'] = $text2; | ||
| 188 | } | 205 | } |
| 189 | $param['route'] = RouteMap::setRoute($param['route'], RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); | 206 | $param['route'] = RouteMap::setRoute($param['route'], RouteMap::SOURCE_AI_BLOG, $id, $this->user['project_id']); |
| 190 | $this->model->edit($param,['id'=>$param['id']]); | 207 | $this->model->edit($param,['id'=>$param['id']]); |
-
请 注册 或 登录 后发表评论