Package com.alibaba.cloud.ai.util
Class StreamingChatGeneratorUtil.StreamingProcessorBuilder
java.lang.Object
com.alibaba.cloud.ai.util.StreamingChatGeneratorUtil.StreamingProcessorBuilder
- Enclosing class:
- StreamingChatGeneratorUtil
-
Method Summary
Modifier and TypeMethodDescriptionAsyncGenerator<? extends NodeOutput>build(reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> sourceFlux) Build streaming processorbusinessLogicExecutor(Function<OverAllState, Map<String, Object>> businessLogicExecutor) Set business logic executor (used to execute business logic in mapResult)completionMessage(String completionMessage) contentExtractor(Function<org.springframework.ai.chat.model.ChatResponse, String> contentExtractor) Set node class (automatically extract class name as node name)Set node nameSet result mapping function (convert collected content to final returned Map)startMessage(String startMessage) state(OverAllState state) Set statetrimResult(boolean trimResult) Set whether to trim the final resulttype(StreamResponseType type)
-
Method Details
-
startMessage
-
completionMessage
public StreamingChatGeneratorUtil.StreamingProcessorBuilder completionMessage(String completionMessage) -
type
-
contentExtractor
public StreamingChatGeneratorUtil.StreamingProcessorBuilder contentExtractor(Function<org.springframework.ai.chat.model.ChatResponse, String> contentExtractor) -
nodeName
Set node name -
nodeClass
Set node class (automatically extract class name as node name) -
state
Set state -
resultMapper
public StreamingChatGeneratorUtil.StreamingProcessorBuilder resultMapper(Function<String, Map<String, Object>> resultMapper) Set result mapping function (convert collected content to final returned Map) -
trimResult
Set whether to trim the final result -
businessLogicExecutor
public StreamingChatGeneratorUtil.StreamingProcessorBuilder businessLogicExecutor(Function<OverAllState, Map<String, Object>> businessLogicExecutor) Set business logic executor (used to execute business logic in mapResult) -
build
public AsyncGenerator<? extends NodeOutput> build(reactor.core.publisher.Flux<org.springframework.ai.chat.model.ChatResponse> sourceFlux) Build streaming processor- Parameters:
sourceFlux- source data stream- Returns:
- AsyncGenerator instance
-