类 StreamUserInput

java.lang.Object
io.agentscope.core.agent.user.StreamUserInput
所有已实现的接口:
UserInputBase

public class StreamUserInput extends Object implements UserInputBase
Stream-based user input implementation that reads from any InputStream and writes to any OutputStream. By default, uses System.in and System.out for console interaction.

Supports both simple text input and structured data input via key=value pairs. Blocking I/O operations are executed on the bounded elastic scheduler to maintain reactive compatibility.

Usage examples:


 // Default console input/output
 StreamUserInput consoleInput = StreamUserInput.builder().build();

 // Custom streams (e.g., for testing)
 StreamUserInput customInput = StreamUserInput.builder()
     .inputStream(myInputStream)
     .outputStream(myOutputStream)
     .inputHint("Enter: ")
     .build();
 
  • 方法详细资料

    • builder

      public static StreamUserInput.Builder builder()
      Create a new builder for StreamUserInput.
      返回:
      A new builder instance
    • handleInput

      public reactor.core.publisher.Mono<UserInputData> handleInput(String agentId, String agentName, List<Msg> contextMessages, Class<?> structuredModel)
      Handle user input from the configured input stream. Prints any context messages before prompting the user with the configured input hint, reads a line of text, and optionally collects structured data if a model class is provided. Returns a UserInputData containing both the text content blocks and any structured input.
      指定者:
      handleInput 在接口中 UserInputBase
      参数:
      agentId - The agent identifier (unused in this implementation)
      agentName - The agent name (unused in this implementation)
      contextMessages - Optional messages to display before prompting (e.g., assistant response)
      structuredModel - Optional class for structured input format
      返回:
      Mono containing the user input data