forked from github/copilot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserInputHandler.java
More file actions
43 lines (39 loc) · 1.46 KB
/
UserInputHandler.java
File metadata and controls
43 lines (39 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
import java.util.concurrent.CompletableFuture;
/**
* Handler for user input requests from the agent.
* <p>
* Implement this interface to handle user input requests when the agent uses
* the ask_user tool.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* 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();
* }</pre>
*
* @since 1.0.6
*/
@FunctionalInterface
public interface UserInputHandler {
/**
* Handles a user input request from the agent.
*
* @param request
* the user input request containing the question and optional
* choices
* @param invocation
* context information about the invocation
* @return a future that resolves with the user's response
*/
CompletableFuture<UserInputResponse> handle(UserInputRequest request, UserInputInvocation invocation);
}