-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMessageOptions.java.html
More file actions
227 lines (208 loc) · 9.34 KB
/
Copy pathMessageOptions.java.html
File metadata and controls
227 lines (208 loc) · 9.34 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang=""><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>MessageOptions.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub Copilot SDK :: Java</a> > <a href="index.source.html" class="el_package">com.github.copilot.rpc</a> > <span class="el_source">MessageOptions.java</span></div><h1>MessageOptions.java</h1><pre class="source lang-java linenums">/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.rpc;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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>
*
* <h2>Blob Attachment Example</h2>
*
* <pre>{@code
* var options = new MessageOptions().setPrompt("Describe this image").setAttachments(List.of(new BlobAttachment()
* .setData("iVBORw0KGgoAAAANSUhEUg...").setMimeType("image/png").setDisplayName("screenshot.png")));
*
* session.send(options).get();
* }</pre>
*
* @see com.github.copilot.CopilotSession#send(MessageOptions)
* @since 1.0.0
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
<span class="nc" id="L43">public class MessageOptions {</span>
private String prompt;
private List<MessageAttachment> attachments;
private String mode;
private AgentMode agentMode;
private Map<String, String> requestHeaders;
private String displayPrompt;
/**
* Gets the message prompt.
*
* @return the prompt text
*/
public String getPrompt() {
<span class="nc" id="L58"> return prompt;</span>
}
/**
* 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) {
<span class="nc" id="L69"> this.prompt = prompt;</span>
<span class="nc" id="L70"> return this;</span>
}
/**
* Gets the attachments.
*
* @return the list of attachments
*/
public List<MessageAttachment> getAttachments() {
<span class="nc bnc" id="L79" title="All 2 branches missed."> return attachments == null ? null : Collections.unmodifiableList(attachments);</span>
}
/**
* Sets attachments to include with the message.
* <p>
* Attachments provide additional context to the assistant. Supported types:
* <ul>
* <li>{@link Attachment} — file, directory, code selection, or GitHub
* reference</li>
* <li>{@link BlobAttachment} — inline base64-encoded binary data (e.g. images)
* </li>
* </ul>
*
* @param attachments
* the list of attachments
* @return this options instance for method chaining
* @see Attachment
* @see BlobAttachment
*/
public MessageOptions setAttachments(List<? extends MessageAttachment> attachments) {
<span class="nc bnc" id="L100" title="All 2 branches missed."> this.attachments = attachments != null ? new ArrayList<>(attachments) : null;</span>
<span class="nc" id="L101"> return this;</span>
}
/**
* 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) {
<span class="nc" id="L118"> this.mode = mode;</span>
<span class="nc" id="L119"> return this;</span>
}
/**
* Gets the delivery mode.
*
* @return the delivery mode
*/
public String getMode() {
<span class="nc" id="L128"> return mode;</span>
}
/**
* Sets the per-message agent UI mode.
* <p>
* Defaults to the session's current mode when unset.
*
* @param agentMode
* the agent mode (for example {@link AgentMode#PLAN} or
* {@link AgentMode#AUTOPILOT})
* @return this options instance for method chaining
*/
public MessageOptions setAgentMode(AgentMode agentMode) {
<span class="nc" id="L142"> this.agentMode = agentMode;</span>
<span class="nc" id="L143"> return this;</span>
}
/**
* Gets the per-message agent UI mode.
*
* @return the agent mode, or {@code null} if not set
*/
public AgentMode getAgentMode() {
<span class="nc" id="L152"> return agentMode;</span>
}
/**
* Gets the custom per-turn HTTP headers for outbound model requests.
*
* @return the headers map, or {@code null} if not set
*/
public Map<String, String> getRequestHeaders() {
<span class="nc bnc" id="L161" title="All 2 branches missed."> return requestHeaders == null ? null : Collections.unmodifiableMap(requestHeaders);</span>
}
/**
* Sets custom per-turn HTTP headers for outbound model requests.
* <p>
* These headers are included in the model API request for this specific message
* turn. Use this to pass per-request authentication, tracing, or custom
* metadata.
*
* @param requestHeaders
* the headers map
* @return this options instance for method chaining
*/
public MessageOptions setRequestHeaders(Map<String, String> requestHeaders) {
<span class="nc" id="L176"> this.requestHeaders = requestHeaders;</span>
<span class="nc" id="L177"> return this;</span>
}
/**
* Gets the display prompt shown in the timeline instead of the prompt.
*
* @return the display prompt, or {@code null} if not set
*/
public String getDisplayPrompt() {
<span class="nc" id="L186"> return displayPrompt;</span>
}
/**
* Sets the display prompt shown in the timeline instead of the prompt.
* <p>
* If provided, this text is displayed in the conversation timeline UI instead
* of the actual prompt text.
*
* @param displayPrompt
* the display prompt text
* @return this options instance for method chaining
*/
public MessageOptions setDisplayPrompt(String displayPrompt) {
<span class="nc" id="L200"> this.displayPrompt = displayPrompt;</span>
<span class="nc" id="L201"> return this;</span>
}
/**
* 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() {
<span class="nc" id="L216"> MessageOptions copy = new MessageOptions();</span>
<span class="nc" id="L217"> copy.prompt = this.prompt;</span>
<span class="nc bnc" id="L218" title="All 2 branches missed."> copy.attachments = this.attachments != null ? new ArrayList<>(this.attachments) : null;</span>
<span class="nc" id="L219"> copy.mode = this.mode;</span>
<span class="nc" id="L220"> copy.agentMode = this.agentMode;</span>
<span class="nc bnc" id="L221" title="All 2 branches missed."> copy.requestHeaders = this.requestHeaders != null ? new HashMap<>(this.requestHeaders) : null;</span>
<span class="nc" id="L222"> copy.displayPrompt = this.displayPrompt;</span>
<span class="nc" id="L223"> return copy;</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.14.202510111229</span></div></body></html>