Interface UserInputHandler

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface UserInputHandler
Handler for user input requests from the agent.

Implement this interface to handle user input requests when the agent uses the ask_user tool.

Example Usage


 UserInputHandler handler = (request, invocation) -> {
 	System.out.println("Agent asks: " + request.getQuestion());
 	String answer = readUserInput(); // your input method
 	return CompletableFuture.completedFuture(new UserInputResponse().setAnswer(answer).setWasFreeform(true));
 };

 var session = client.createSession(new SessionConfig().setOnUserInputRequest(handler)).get();
 
Since:
1.0.6
  • Method Details

    • handle

      Handles a user input request from the agent.
      Parameters:
      request - the user input request containing the question and optional choices
      invocation - context information about the invocation
      Returns:
      a future that resolves with the user's response