作者 lyh

gx脚本

... ... @@ -13,6 +13,7 @@ use App\Models\Ai\AiLog;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Models\Project\ProjectKeyword;
use App\Services\AiCommandService;
use Illuminate\Support\Facades\Cache;
class AiCommandController extends BaseController
... ... @@ -113,4 +114,27 @@ class AiCommandController extends BaseController
}
$this->response('success', Code::SUCCESS, ['id'=>$id]);
}
/**
* @remark :根据指令获取内容
* @name :sendLayoutDesign
* @author :lyh
* @method :post
* @time :2025/5/26 17:39
*/
public function sendLayoutDesign(){
$this->request->validate([
'key'=>['required']
],[
'key.required' => '场景不能为空',
]);
$aiCommonModel = new AiCommand();
$info = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>$this->user['project_id']]);
if($info === false){
$info = $aiCommonModel->read(['key'=>'ai_layout_design','project_id'=>0]);
}
$aiCommandService = new AiCommandService();
$result = $aiCommandService->send_layout_design($info['ai']);
$this->response('success', Code::SUCCESS, $result);
}
}
... ...
... ... @@ -22,6 +22,10 @@ class AiCommandService
public $api_key = 'nnLsyr3IhPNsJt5OvTtD9SVCLEixMntg';
public $model = 'gemini-2.0-flash-lite';
public $supplier = 'google';
/**
* @remark :Ai一键排版
* @name :ai_click_layout
... ... @@ -29,29 +33,23 @@ class AiCommandService
* @method :post
* @time :2025/5/26 17:03
*/
public function ai_click_layout(){
public function send_layout_design($content){
$param = [
'messages'=>[
'content'=>'',
'content'=>$content,
'role'=>'user',
],
'model'=> 'gemini-2.0-flash-lite',
'supplier'=> 'google',
'model'=> $this->model,
'supplier'=> $this->supplier,
'security_check'=> false
];
$header = [
'accept'=>'application/json',
'X-CmerApi-Host'=>'llm-chat.p.cmer.com',
'apikey'=>$this->api_key,
'Content-Type'=>'application/json'
];
$header = array(
"Accept: application/json",
"X-CmerApi-Host: llm-chat.p.cmer.com",
"apikey: $this->api_key",
"Content-Type:application/json;charset=utf-8",
);
$result = http_post($this->url,$param,$header);
$result = http_post($this->url,json_encode($param,true),$header);
return $result;
}
}
... ...