在大模型应用(如智能客服、聊天机器人、内容生成平台)中,SafeGuardAdvisor 这类敏感词过滤组件的核心价值,是在大模型交互全链路中建立合规与安全屏障,既规避业务合规风险,也保障用户体验和平台声誉
语法:
new SafeGuardAdvisor(List.of("曹操"))
应用
package com.xzx.springai;
import org.junit.jupiter.api.Test;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.SafeGuardAdvisor;
import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
public class TestAdvisor {
@Test
public void test(@Autowired ChatClient.Builder chatClientBuilder) {
ChatClient chatClient = chatClientBuilder
.defaultAdvisors(new SafeGuardAdvisor(List.of("董卓"),"含有敏感词",1))
.build();
String content = chatClient.prompt().user("董卓大奸臣").call().content();
System.out.println(content);
}
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...


