forked from github/copilot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElicitationHandler.java
More file actions
44 lines (40 loc) · 1.57 KB
/
ElicitationHandler.java
File metadata and controls
44 lines (40 loc) · 1.57 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
44
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
import java.util.concurrent.CompletableFuture;
/**
* Functional interface for handling elicitation requests from the server.
* <p>
* Register an elicitation handler via
* {@link SessionConfig#setOnElicitationRequest(ElicitationHandler)} or
* {@link ResumeSessionConfig#setOnElicitationRequest(ElicitationHandler)}. When
* provided, the server routes elicitation requests to this handler and reports
* elicitation as a supported capability.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* ElicitationHandler handler = context -> {
* // Show the form to the user and collect responses
* Map<String, Object> formValues = showForm(context.getMessage(), context.getRequestedSchema());
* return CompletableFuture.completedFuture(
* new ElicitationResult().setAction(ElicitationResultAction.ACCEPT).setContent(formValues));
* };
* }</pre>
*
* @see ElicitationContext
* @see ElicitationResult
* @since 1.0.0
*/
@FunctionalInterface
public interface ElicitationHandler {
/**
* Handles an elicitation request from the server.
*
* @param context
* the elicitation context containing the message, schema, and mode
* @return a future that resolves with the elicitation result
*/
CompletableFuture<ElicitationResult> handle(ElicitationContext context);
}