|
@@ -50,11 +50,12 @@ class ChatLogic extends BaseLogic |
|
@@ -50,11 +50,12 @@ class ChatLogic extends BaseLogic |
|
50
|
'message'=>$message,
|
50
|
'message'=>$message,
|
|
51
|
];
|
51
|
];
|
|
52
|
$result = $gptService->get_ai_chat($data);
|
52
|
$result = $gptService->get_ai_chat($data);
|
|
|
|
53
|
+ $this->saveChatItem($chatInfo['id'],$result['text'] ?? '服务器繁忙,请重试',1);
|
|
|
|
54
|
+ return $this->success($result);
|
|
53
|
}
|
55
|
}
|
|
54
|
}
|
56
|
}
|
|
55
|
-// $id = $this->saveChat($this->param['message']);
|
|
|
|
56
|
-// $this->saveChatItem($id,$this->param['message']);
|
|
|
|
57
|
-
|
57
|
+ $id = $this->saveChat($this->param['message']);
|
|
|
|
58
|
+ $this->saveChatItem($id,$this->param['message']);
|
|
58
|
$data = [
|
59
|
$data = [
|
|
59
|
'message'=>[
|
60
|
'message'=>[
|
|
60
|
['role' => 'system', 'content' => "You are now the marketing customer service of 深圳创贸集团"],
|
61
|
['role' => 'system', 'content' => "You are now the marketing customer service of 深圳创贸集团"],
|
|
@@ -62,7 +63,8 @@ class ChatLogic extends BaseLogic |
|
@@ -62,7 +63,8 @@ class ChatLogic extends BaseLogic |
|
62
|
],
|
63
|
],
|
|
63
|
];
|
64
|
];
|
|
64
|
$result = $gptService->get_ai_chat($data);
|
65
|
$result = $gptService->get_ai_chat($data);
|
|
65
|
- $this->success($result);
|
66
|
+ $this->saveChatItem($id,$result['text'] ?? '服务器繁忙,请重试',1);
|
|
|
|
67
|
+ return $this->success($result);
|
|
66
|
}
|
68
|
}
|
|
67
|
|
69
|
|
|
68
|
/**
|
70
|
/**
|
|
@@ -88,11 +90,11 @@ class ChatLogic extends BaseLogic |
|
@@ -88,11 +90,11 @@ class ChatLogic extends BaseLogic |
|
88
|
* @method :post
|
90
|
* @method :post
|
|
89
|
* @time :2025/4/2 13:45
|
91
|
* @time :2025/4/2 13:45
|
|
90
|
*/
|
92
|
*/
|
|
91
|
- public function saveChatItem($id,$message){
|
93
|
+ public function saveChatItem($id,$message,$is_reply = 2){
|
|
92
|
//创建一个会话
|
94
|
//创建一个会话
|
|
93
|
$saveData = [
|
95
|
$saveData = [
|
|
94
|
'user_id'=>$this->user['id'],
|
96
|
'user_id'=>$this->user['id'],
|
|
95
|
- 'is_reply'=>2,
|
97
|
+ 'is_reply'=>$is_reply,
|
|
96
|
'chat_id'=>$id,
|
98
|
'chat_id'=>$id,
|
|
97
|
'content'=>$message,
|
99
|
'content'=>$message,
|
|
98
|
];
|
100
|
];
|