feat(ai): 集成DashScope AI聊天功能并配置加密支持
- 添加DashScope AI配置项,包括API密钥和模型参数 - 实现ChatClient配置类用于构建AI聊天客户端 - 创建控制器接口支持用户通过HTTP请求与AI交互 - 引入Jasypt加密库用于敏感信息加密 - 添加Spring AI和Alibaba DashScope依赖管理- 升级项目依赖并引入WebFlux支持异步处理
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.hanserwei.snailsai.controller;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
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;
|
||||
|
||||
@RequestMapping("/dashscope")
|
||||
@RestController
|
||||
public class DashScopeController {
|
||||
|
||||
@Resource
|
||||
private ChatClient dashScopeChatClient;
|
||||
|
||||
@GetMapping("/chat")
|
||||
public String chat(@RequestParam("userPrompt") String userPrompt) {
|
||||
return dashScopeChatClient.prompt()
|
||||
.user(userPrompt)
|
||||
.call()
|
||||
.content();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user