AiCommandController.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace App\Http\Controllers\Bside\Ai;
use App\Enums\Common\Code;
use App\Helper\Common;
use App\Helper\Translate;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Controllers\Bside\:写入日志;
use App\Http\Logic\Bside\Ai\AiCommandLogic;
use App\Models\Ai\AiCommand;
use App\Models\Ai\AiLog;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
class AiCommandController extends BaseController
{
/**
* @author zbj
* @date 2023/11/22
*/
public function ai_http_post(){
$this->request->validate([
'keywords'=>['required'],
'key'=>['required']
],[
'keywords.required' => '关键字不能为空',
'key.required' => '场景不能为空',
]);
$text = AiCommandLogic::instance()->ai_send();
$data = [
'code' => $text ? 200 : 500,
'text' => $text
];
$param = [
'key' => $this->param['key'],
'keywords' => $this->param['keywords'],
'remark' => $text
];
$this->set_ai_log($param);
$this->response('success', Code::SUCCESS, $data);
}
/**
* @name :写入日志
* @author :liyuhang
* @method
*/
public function set_ai_log($data){
//写入日志
$param = [
'key'=> $this->param['key'],
'keywords'=>$this->param['keywords'],
'remark' =>$data['remark'],
'operator_id'=>$this->uid
];
$aiLog = new AiLog();
return $aiLog->add($param);
}
}