forked from github/copilot-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageOptions.java
More file actions
130 lines (117 loc) · 3.65 KB
/
MessageOptions.java
File metadata and controls
130 lines (117 loc) · 3.65 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
/**
* Options for sending a message to a Copilot session.
* <p>
* This class specifies the message content and optional attachments to send to
* the assistant. All setter methods return {@code this} for method chaining.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* var options = new MessageOptions().setPrompt("Explain this code")
* .setAttachments(List.of(new Attachment("file", "/path/to/file.java", null)));
*
* session.send(options).get();
* }</pre>
*
* @see com.github.copilot.sdk.CopilotSession#send(MessageOptions)
* @since 1.0.0
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class MessageOptions {
private String prompt;
private List<Attachment> attachments;
private String mode;
/**
* Gets the message prompt.
*
* @return the prompt text
*/
public String getPrompt() {
return prompt;
}
/**
* Sets the message prompt to send to the assistant.
*
* @param prompt
* the message text
* @return this options instance for method chaining
*/
public MessageOptions setPrompt(String prompt) {
this.prompt = prompt;
return this;
}
/**
* Gets the file attachments.
*
* @return the list of attachments
*/
public List<Attachment> getAttachments() {
return attachments == null ? null : Collections.unmodifiableList(attachments);
}
/**
* Sets file attachments to include with the message.
* <p>
* Attachments provide additional context to the assistant, such as source code
* files, documents, or other relevant files.
*
* @param attachments
* the list of file attachments
* @return this options instance for method chaining
* @see Attachment
*/
public MessageOptions setAttachments(List<Attachment> attachments) {
this.attachments = attachments;
return this;
}
/**
* Sets the message delivery mode.
* <p>
* Valid modes:
* <ul>
* <li>"enqueue" - Queue the message for processing (default)</li>
* <li>"immediate" - Process the message immediately</li>
* </ul>
*
* @param mode
* the delivery mode
* @return this options instance for method chaining
*/
public MessageOptions setMode(String mode) {
this.mode = mode;
return this;
}
/**
* Gets the delivery mode.
*
* @return the delivery mode
*/
public String getMode() {
return mode;
}
/**
* Creates a shallow clone of this {@code MessageOptions} instance.
* <p>
* Mutable collection properties are copied into new collection instances so
* that modifications to those collections on the clone do not affect the
* original. Other reference-type properties (like attachment items) are not
* deep-cloned; the original and the clone will share those objects.
*
* @return a clone of this options instance
*/
@Override
public MessageOptions clone() {
MessageOptions copy = new MessageOptions();
copy.prompt = this.prompt;
copy.attachments = this.attachments != null ? new ArrayList<>(this.attachments) : null;
copy.mode = this.mode;
return copy;
}
}