作者 lyh

gx

@@ -13,7 +13,6 @@ use App\Enums\Common\Code; @@ -13,7 +13,6 @@ use App\Enums\Common\Code;
13 use App\Helper\FormGlobalsoApi; 13 use App\Helper\FormGlobalsoApi;
14 use App\Helper\PayStripeApi; 14 use App\Helper\PayStripeApi;
15 use App\Helper\Translate; 15 use App\Helper\Translate;
16 -use App\Http\Logic\Bside\Gpt\ChatLogic;  
17 use App\Http\Logic\Bside\News\NewsLogic; 16 use App\Http\Logic\Bside\News\NewsLogic;
18 use App\Models\Ai\AiBlog; 17 use App\Models\Ai\AiBlog;
19 use App\Models\Channel\Channel; 18 use App\Models\Channel\Channel;
@@ -42,13 +41,9 @@ class TestController extends BaseController @@ -42,13 +41,9 @@ class TestController extends BaseController
42 * @method :post 41 * @method :post
43 * @time :2025/2/13 16:34 42 * @time :2025/2/13 16:34
44 */ 43 */
45 - public function ceshi(ChatLogic $logic){  
46 - $this->request->validate([  
47 - 'message'=>['required'],  
48 - ],[  
49 - 'message.required' => '消息内容不能为空',  
50 - ]);  
51 - $data = $logic->sendMessage();  
52 - $this->response('success',Code::SUCCESS,$data); 44 + public function ceshi(){
  45 + //获取上一周询盘数量
  46 + $transData = Translate::tran(['heidenhain programming','heidenhain tnc 620'], 'zh');
  47 + $this->response('success',Code::SUCCESS,$transData);
53 } 48 }
54 } 49 }
@@ -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 ];