langchain.js
    Preparing search index...

    Utility class for working with channels in the Pregel system. Provides static methods for subscribing to channels and writing to them.

    Channels are the communication pathways between nodes in a Pregel graph. They enable message passing and state updates between different parts of the graph.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Creates a PregelNode that subscribes to a single channel. This is used to define how nodes receive input from channels.

      Parameters

      Returns PregelNode

      A PregelNode configured to receive from the specified channels

      // Subscribe to a single channel
      const node = Channel.subscribeTo("messages");

      // Subscribe to multiple channels
      const node = Channel.subscribeTo(["messages", "state"]);

      // Subscribe with a custom key
      const node = Channel.subscribeTo("messages", { key: "chat" });

      If a key is specified when subscribing to multiple channels

    • Creates a PregelNode that subscribes to multiple channels. This is used to define how nodes receive input from channels.

      Parameters

      Returns PregelNode

      A PregelNode configured to receive from the specified channels

      // Subscribe to a single channel
      const node = Channel.subscribeTo("messages");

      // Subscribe to multiple channels
      const node = Channel.subscribeTo(["messages", "state"]);

      // Subscribe with a custom key
      const node = Channel.subscribeTo("messages", { key: "chat" });

      If a key is specified when subscribing to multiple channels

    • Creates a ChannelWrite that specifies how to write values to channels. This is used to define how nodes send output to channels.

      Parameters

      • channels: string[]

        Array of channel names to write to

      • Optionalwrites: Record<string, unknown>

        Optional map of channel names to values or transformations

      Returns ChannelWrite

      A ChannelWrite object that can be used to write to the specified channels

      // Write to multiple channels
      const write = Channel.writeTo(["output", "state"]);

      // Write with specific values
      const write = Channel.writeTo(["output"], {
      state: "completed",
      result: calculateResult()
      });

      // Write with a transformation function
      const write = Channel.writeTo(["output"], {
      result: (x) => processResult(x)
      });