- 添加 DeepSeek Chat 模型依赖及 starter - 配置 DeepSeek API Key 加密与基础 URL - 新增 DeepSeekChatController 实现基本对话接口 - 引入 Jasypt 加密库用于敏感信息加密 - 提供 EncryptorUtil 工具类用于生成加密密钥 - 更新 pom.xml 引入 spring-ai 和 jasypt 依赖管理
28 lines
842 B
Java
28 lines
842 B
Java
package com.hanserwei.airobot.controller;
|
|
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.ai.deepseek.DeepSeekChatModel;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@RestController
|
|
@RequestMapping("/ai")
|
|
public class DeepSeekChatController {
|
|
|
|
@Resource
|
|
private DeepSeekChatModel chatModel;
|
|
|
|
/**
|
|
* 普通对话
|
|
* @param message 对话输入内容
|
|
* @return 对话结果
|
|
*/
|
|
@GetMapping("/generate")
|
|
public String generate(@RequestParam(value = "message", defaultValue = "你是谁?") String message) {
|
|
// 一次性返回结果
|
|
return chatModel.call(message);
|
|
}
|
|
|
|
} |