Class StreamingChatModelExtensionsKt

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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.