作者 lyh

gx生成评论

... ... @@ -13,6 +13,7 @@ use App\Helper\Common;
use App\Helper\Gpt;
use App\Models\Ai\AiCommand;
use App\Models\Com\NoticeLog;
use App\Models\Project\AggregateKeywordCommon;
use Illuminate\Console\Command;
class InitKeywordCommon extends Command
... ... @@ -34,7 +35,7 @@ class InitKeywordCommon extends Command
public function handle(){
return $this->_action();
return $this->_action(467);
while (true){
$list = NoticeLog::where('type', NoticeLog::TYPE_INIT_KEYWORD_COMMON)->where('status', NoticeLog::STATUS_PENDING)->get();
}
... ... @@ -48,13 +49,27 @@ class InitKeywordCommon extends Command
* @method :post
* @time :2025/6/3 15:42
*/
public function _action(){
public function _action($project_id){
$aiCommonModel = new AiCommand();
$info = $aiCommonModel->read(['key'=>'tag_comment']);
$text = Gpt::instance()->openai_chat_qqs($info['ai']);
$text = Common::deal_keywords($text);
$text = Common::deal_str($text);
$text = preg_match_all('/\{[^{}]*\}/', $text, $matches);
dd($matches[0]);
return Common::deal_str($text);
if(!empty($text)){
$data = [];
foreach ($text as $item){
$data[] = [
'nickname'=>$item['name'],
'text'=>$item['comment'],
'project_id'=>$project_id,
'type'=>1,
'uid'=>0,
];
}
$keywordCommonModel = new AggregateKeywordCommon();
$keywordCommonModel->insertAll($data);
}
return true;
}
}
... ...
<?php
/**
* @remark :
* @name :AggregateKeywordCommon.php
* @author :lyh
* @method :post
* @time :2025/6/3 17:42
*/
namespace App\Models\Project;
use App\Models\Base;
class AggregateKeywordCommon extends Base
{
protected $table = 'gl_aggregate_keyword_common';
}
... ...