Class StructuredOutputValidationAdvisor
java.lang.Object
org.springframework.ai.chat.client.advisor.StructuredOutputValidationAdvisor
- All Implemented Interfaces:
Advisor,CallAdvisor,StreamAdvisor,org.springframework.core.Ordered
public final class StructuredOutputValidationAdvisor
extends Object
implements CallAdvisor, StreamAdvisor
Recursive Advisor that validates the structured JSON output of a chat client entity
response against a generated JSON schema for the expected output type.
If the validation fails, the advisor will repeat the call up to a specified number of attempts.
Note: This advisor does not support streaming responses and will throw an UnsupportedOperationException if used in a streaming context.
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder class for StructuredOutputValidationAdvisor. -
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 -
Method Summary
Modifier and TypeMethodDescriptionadviseCall(ChatClientRequest chatClientRequest, CallAdvisorChain callAdvisorChain) reactor.core.publisher.Flux<ChatClientResponse>adviseStream(ChatClientRequest chatClientRequest, StreamAdvisorChain streamAdvisorChain) builder()Creates a new Builder for StructuredOutputValidationAdvisor.getName()Return the name of the advisor.intgetOrder()
-
Method Details
-
getName
Description copied from interface:AdvisorReturn the name of the advisor. -
getOrder
public int getOrder()- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
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
-
builder
Creates a new Builder for StructuredOutputValidationAdvisor.- Returns:
- a new Builder instance
-