✨Feat: 完成 LLM 接入
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.wonderland.stardewvalley.ai;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ChatUtil {
|
||||
|
||||
private final ChatClient chatClient;
|
||||
|
||||
public ChatUtil(ChatClient.Builder chatClientBuilder) {
|
||||
this.chatClient = chatClientBuilder.build();
|
||||
}
|
||||
|
||||
public String doChat(String background, String input) {
|
||||
String content = chatClient
|
||||
.prompt()
|
||||
.system("你是一个AI助手,请根据背景和输入生成回复")
|
||||
.user("[BackGround]: " + background + "\n[Input]: " + input)
|
||||
.call()
|
||||
.content();
|
||||
return content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user