forked from github/copilot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserPromptSubmittedHandler.java
More file actions
43 lines (39 loc) · 1.45 KB
/
UserPromptSubmittedHandler.java
File metadata and controls
43 lines (39 loc) · 1.45 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-prompt-submitted hooks.
* <p>
* This handler is invoked when the user submits a prompt, allowing you to
* intercept and modify the prompt before it is processed.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* UserPromptSubmittedHandler handler = (input, invocation) -> {
* System.out.println("User submitted: " + input.getPrompt());
* // Optionally modify the prompt
* return CompletableFuture.completedFuture(
* new UserPromptSubmittedHookOutput().setModifiedPrompt(input.getPrompt() + " (enhanced)"));
* };
* }</pre>
*
* @since 1.0.7
*/
@FunctionalInterface
public interface UserPromptSubmittedHandler {
/**
* Handles a user prompt submission event.
*
* @param input
* the hook input containing the prompt details
* @param invocation
* metadata about the hook invocation
* @return a future that resolves with the hook output, or {@code null} to
* proceed without modification
*/
CompletableFuture<UserPromptSubmittedHookOutput> handle(UserPromptSubmittedHookInput input,
HookInvocation invocation);
}