|
...
|
...
|
@@ -50,11 +50,12 @@ class ChatLogic extends BaseLogic |
|
|
|
'message'=>$message,
|
|
|
|
];
|
|
|
|
$result = $gptService->get_ai_chat($data);
|
|
|
|
$this->saveChatItem($chatInfo['id'],$result['text'] ?? '服务器繁忙,请重试',1);
|
|
|
|
return $this->success($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// $id = $this->saveChat($this->param['message']);
|
|
|
|
// $this->saveChatItem($id,$this->param['message']);
|
|
|
|
|
|
|
|
$id = $this->saveChat($this->param['message']);
|
|
|
|
$this->saveChatItem($id,$this->param['message']);
|
|
|
|
$data = [
|
|
|
|
'message'=>[
|
|
|
|
['role' => 'system', 'content' => "You are now the marketing customer service of 深圳创贸集团"],
|
|
...
|
...
|
@@ -62,7 +63,8 @@ class ChatLogic extends BaseLogic |
|
|
|
],
|
|
|
|
];
|
|
|
|
$result = $gptService->get_ai_chat($data);
|
|
|
|
$this->success($result);
|
|
|
|
$this->saveChatItem($id,$result['text'] ?? '服务器繁忙,请重试',1);
|
|
|
|
return $this->success($result);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -88,11 +90,11 @@ class ChatLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2025/4/2 13:45
|
|
|
|
*/
|
|
|
|
public function saveChatItem($id,$message){
|
|
|
|
public function saveChatItem($id,$message,$is_reply = 2){
|
|
|
|
//创建一个会话
|
|
|
|
$saveData = [
|
|
|
|
'user_id'=>$this->user['id'],
|
|
|
|
'is_reply'=>2,
|
|
|
|
'is_reply'=>$is_reply,
|
|
|
|
'chat_id'=>$id,
|
|
|
|
'content'=>$message,
|
|
|
|
];
|
...
|
...
|
|