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

Happy_EveryDay

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

sb-deepseek-chatclient聊天20250703

参考:  sb-deepseek20250703

1、application.properties

spring.application.name=ai-chat
server.port=8899

spring.ai.openai.api-key=sk-595b6ce15e1c4a16b1bbae6b8ee16a4d
spring.ai.openai.base-url=https://api.deepseek.com
spring.ai.openai.chat.options.model=deepseek-chat
spring.ai.openai.chat.options.temperature=0.7


2、
package com.ds.aichat.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ChatDeepSeekController {
private final ChatClient chatClient;
public ChatDeepSeekController(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder.build();
}

@GetMapping("/chat")
public String chat(@RequestParam(value = "msg", defaultValue = "给我讲个笑话吧")
String message) {
//提示词
return chatClient.prompt()
//用户输入信息
.user( message)
//模型调用
.call()
//返回文本
.content();
}
}

3、

 

posted on 2025-07-13 02:35  cn2025  阅读(12)  评论(0)    收藏  举报

导航