Dict.CN 在线词典, 英语学习, 在线翻译 ------------- MyGitee My腾云code

Happy_EveryDay

可以平凡 不可以平庸 无爱则无忧,无欲则无求,无怒而无敌,无怨才是佛。所有烦恼,都是放不下的执著 开源技群 328035181 MyGitee

sb-deepseek-chatModel聊天20250713

参考:  sb-deepseek20250703

 

1、

package com.ds.aichat.controller;

import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.ai.openai.OpenAiChatOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChatModelController {
@Autowired
private ChatModel chatModel;

@GetMapping("/chatModel01")
public String chatModel01(@RequestParam("msg") String msg) {
String result = chatModel.call(msg);
return result;
}

@GetMapping("/chatModel02")
public String chatModel02(@RequestParam("msg") String msg) {
ChatResponse chatResponse=chatModel.call(
new Prompt(
msg,
OpenAiChatOptions.builder()
.model("deepseek-chat")
.temperature(0.8)
.build()
)

);
String content = chatResponse.getResult().getOutput().getText();
return content;
}
}

2、

 

 




posted on 2025-07-13 15:56  cn2025  阅读(17)  评论(0)    收藏  举报

导航