Class SafeGuardAdvisor
java.lang.Object
org.springframework.ai.chat.client.advisor.SafeGuardAdvisor
- All Implemented Interfaces:
Advisor,CallAdvisor,StreamAdvisor,org.springframework.core.Ordered
An advisor that blocks the call to the model provider if the user input contains any of
the sensitive words.
- Since:
- 1.0.0
- Author:
- Christian Tzolov, Ilayaperumal Gopinathan, Thomas Vitale
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from interface org.springframework.ai.chat.client.advisor.api.Advisor
DEFAULT_CHAT_MEMORY_PRECEDENCE_ORDERFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionSafeGuardAdvisor(List<String> sensitiveWords) SafeGuardAdvisor(List<String> sensitiveWords, String failureResponse, int order) -
Method Summary
Modifier and TypeMethodDescriptionadviseCall(ChatClientRequest chatClientRequest, CallAdvisorChain callAdvisorChain) reactor.core.publisher.Flux<ChatClientResponse>adviseStream(ChatClientRequest chatClientRequest, StreamAdvisorChain streamAdvisorChain) static SafeGuardAdvisor.Builderbuilder()getName()Return the name of the advisor.intgetOrder()
-
Constructor Details
-
SafeGuardAdvisor
-
SafeGuardAdvisor
-
-
Method Details
-
builder
-
getName
Description copied from interface:AdvisorReturn the name of the advisor. -
adviseCall
public ChatClientResponse adviseCall(ChatClientRequest chatClientRequest, CallAdvisorChain callAdvisorChain) - Specified by:
adviseCallin interfaceCallAdvisor
-
adviseStream
public reactor.core.publisher.Flux<ChatClientResponse> adviseStream(ChatClientRequest chatClientRequest, StreamAdvisorChain streamAdvisorChain) - Specified by:
adviseStreamin interfaceStreamAdvisor
-
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-