Class StreamingChatModelExtensionsKt
-
- All Implemented Interfaces:
public final class StreamingChatModelExtensionsKt
-
-
Method Summary
Modifier and Type Method Description final static Flow<StreamingChatModelReply>chatFlow(StreamingChatModel $self, Function1<ChatRequestBuilder, Unit> block)Converts a streaming chat model into a Kotlin Flow of StreamingChatModelReply events. -
-
Method Detail
-
chatFlow
final static Flow<StreamingChatModelReply> chatFlow(StreamingChatModel $self, Function1<ChatRequestBuilder, Unit> block)
Converts a streaming chat model into a Kotlin Flow of StreamingChatModelReply events. This extension function provides a coroutine-friendly way to consume streaming responses from the language model.
The method uses a provided configuration block to build a chat request and manages the streaming process by handling partial responses, complete responses, and errors through a LC4J's dev.langchain4j.model.chat.response.StreamingChatResponseHandler.
- Parameters:
block- A lambda with receiver on ChatRequestBuilder used to configure the dev.langchain4j.model.chat.request.ChatRequest by adding messages and/or setting parameters.- Returns:
A Flow of StreamingChatModelReply, which emits different types of replies during the chat interaction, including partial responses, final responses, and errors.
-
-
-
-