Interface BaseAdvisor
- All Superinterfaces:
Advisor,CallAdvisor,org.springframework.core.Ordered,StreamAdvisor
- All Known Subinterfaces:
BaseChatMemoryAdvisor
- All Known Implementing Classes:
MessageChatMemoryAdvisor,PromptChatMemoryAdvisor
Base advisor that implements common aspects of the
CallAdvisor and
StreamAdvisor, reducing the boilerplate code needed to implement an advisor.
It provides default implementations for the
adviseCall(ChatClientRequest, CallAdvisorChain) and
adviseStream(ChatClientRequest, StreamAdvisorChain) methods, delegating the
actual logic to the before(ChatClientRequest, AdvisorChain advisorChain) and
after(ChatClientResponse, AdvisorChain advisorChain) methods.
- Since:
- 1.0.0
- Author:
- Thomas Vitale
-
Field Summary
FieldsFields 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 -
Method Summary
Modifier and TypeMethodDescriptiondefault ChatClientResponseadviseCall(ChatClientRequest chatClientRequest, CallAdvisorChain callAdvisorChain) default reactor.core.publisher.Flux<ChatClientResponse>adviseStream(ChatClientRequest chatClientRequest, StreamAdvisorChain streamAdvisorChain) after(ChatClientResponse chatClientResponse, AdvisorChain advisorChain) Logic to be executed after the rest of the advisor chain is called.before(ChatClientRequest chatClientRequest, AdvisorChain advisorChain) Logic to be executed before the rest of the advisor chain is called.default StringgetName()Return the name of the advisor.default reactor.core.scheduler.SchedulerScheduler used for processing the advisor logic when streaming.Methods inherited from interface org.springframework.core.Ordered
getOrder
-
Field Details
-
DEFAULT_SCHEDULER
static final reactor.core.scheduler.Scheduler DEFAULT_SCHEDULER
-
-
Method Details
-
adviseCall
default ChatClientResponse adviseCall(ChatClientRequest chatClientRequest, CallAdvisorChain callAdvisorChain) - Specified by:
adviseCallin interfaceCallAdvisor
-
adviseStream
default reactor.core.publisher.Flux<ChatClientResponse> adviseStream(ChatClientRequest chatClientRequest, StreamAdvisorChain streamAdvisorChain) - Specified by:
adviseStreamin interfaceStreamAdvisor
-
getName
Description copied from interface:AdvisorReturn the name of the advisor. -
before
Logic to be executed before the rest of the advisor chain is called. -
after
Logic to be executed after the rest of the advisor chain is called. -
getScheduler
default reactor.core.scheduler.Scheduler getScheduler()Scheduler used for processing the advisor logic when streaming.
-