Skip to content

Commit d269a2b

Browse files
ethanyhouCopilot
andauthored
feat: Update Copilot model capabilities with context size and token limits, and hover details (#165)
Co-authored-by: Copilot <copilot@github.com>
1 parent 44e86cd commit d269a2b

15 files changed

Lines changed: 339 additions & 72 deletions

File tree

com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/protocol/CopilotModel.java

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class CopilotModel {
1616
private String modelFamily;
1717
private String modelName;
1818
private String id;
19+
private String vendor;
1920
private CopilotModelPolicy modelPolicy;
2021
private List<String> scopes;
2122
private boolean preview;
@@ -26,6 +27,7 @@ public class CopilotModel {
2627
private String degradationReason;
2728
private String providerName;
2829
private String modelPickerCategory;
30+
private String modelPickerPriceCategory;
2931

3032
/**
3133
* Policy for the model.
@@ -52,27 +54,65 @@ public String toString() {
5254
}
5355
}
5456

57+
/**
58+
* Capabilities limits for the model. All components are optional ({@code null} when the server does not provide a
59+
* value), mirroring the {@code number | undefined} fields in the language-server schema.
60+
*/
61+
public record CopilotModelCapabilitiesLimits(Integer maxContextWindowTokens, Integer maxOutputTokens,
62+
Integer maxInputTokens, Integer maxNonStreamingOutputTokens) {
63+
@Override
64+
public String toString() {
65+
ToStringBuilder builder = new ToStringBuilder(this);
66+
builder.append("maxContextWindowTokens", maxContextWindowTokens);
67+
builder.append("maxOutputTokens", maxOutputTokens);
68+
builder.append("maxInputTokens", maxInputTokens);
69+
builder.append("maxNonStreamingOutputTokens", maxNonStreamingOutputTokens);
70+
return builder.toString();
71+
}
72+
}
73+
5574
/**
5675
* Capabilities for the model.
5776
*/
58-
public record CopilotModelCapabilities(CopilotModelCapabilitiesSupports supports) {
77+
public record CopilotModelCapabilities(CopilotModelCapabilitiesSupports supports,
78+
CopilotModelCapabilitiesLimits limits) {
5979
@Override
6080
public String toString() {
6181
ToStringBuilder builder = new ToStringBuilder(this);
6282
builder.append("supports", supports);
83+
builder.append("limits", limits);
84+
return builder.toString();
85+
}
86+
}
87+
88+
/**
89+
* Per-token prices for the model, returned in USD.
90+
*/
91+
public record CopilotModelBillingTokenPrices(Double cachePrice, Double inputPrice, Double outputPrice,
92+
Double tokenUnit) {
93+
@Override
94+
public String toString() {
95+
ToStringBuilder builder = new ToStringBuilder(this);
96+
builder.append("cachePrice", cachePrice);
97+
builder.append("inputPrice", inputPrice);
98+
builder.append("outputPrice", outputPrice);
99+
builder.append("tokenUnit", tokenUnit);
63100
return builder.toString();
64101
}
65102
}
66103

67104
/**
68105
* Billing for the model.
69106
*/
70-
public record CopilotModelBilling(boolean isPremium, double multiplier) {
107+
public record CopilotModelBilling(boolean isPremium, double multiplier, boolean tokenBasedBillingEnabled,
108+
CopilotModelBillingTokenPrices tokenPrices) {
71109
@Override
72110
public String toString() {
73111
ToStringBuilder builder = new ToStringBuilder(this);
74112
builder.append("isPremium", isPremium);
75113
builder.append("multiplier", multiplier);
114+
builder.append("tokenBasedBillingEnabled", tokenBasedBillingEnabled);
115+
builder.append("tokenPrices", tokenPrices);
76116
return builder.toString();
77117
}
78118
}
@@ -101,6 +141,14 @@ public void setId(String id) {
101141
this.id = id;
102142
}
103143

144+
public String getVendor() {
145+
return vendor;
146+
}
147+
148+
public void setVendor(String vendor) {
149+
this.vendor = vendor;
150+
}
151+
104152
public CopilotModelPolicy getModelPolicy() {
105153
return modelPolicy;
106154
}
@@ -181,6 +229,14 @@ public void setModelPickerCategory(String modelPickerCategory) {
181229
this.modelPickerCategory = modelPickerCategory;
182230
}
183231

232+
public String getModelPickerPriceCategory() {
233+
return modelPickerPriceCategory;
234+
}
235+
236+
public void setModelPickerPriceCategory(String modelPickerPriceCategory) {
237+
this.modelPickerPriceCategory = modelPickerPriceCategory;
238+
}
239+
184240
@Override
185241
public boolean equals(Object obj) {
186242
if (this == obj) {
@@ -198,14 +254,16 @@ public boolean equals(Object obj) {
198254
&& isChatDefault == other.isChatDefault && isChatFallback == other.isChatFallback
199255
&& Objects.equals(modelFamily, other.modelFamily) && Objects.equals(modelName, other.modelName)
200256
&& Objects.equals(modelPickerCategory, other.modelPickerCategory)
257+
&& Objects.equals(modelPickerPriceCategory, other.modelPickerPriceCategory)
201258
&& Objects.equals(modelPolicy, other.modelPolicy) && preview == other.preview
202-
&& Objects.equals(providerName, other.providerName) && Objects.equals(scopes, other.scopes);
259+
&& Objects.equals(providerName, other.providerName) && Objects.equals(scopes, other.scopes)
260+
&& Objects.equals(vendor, other.vendor);
203261
}
204262

205263
@Override
206264
public int hashCode() {
207265
return Objects.hash(billing, capabilities, degradationReason, id, isChatDefault, isChatFallback, modelFamily,
208-
modelName, modelPickerCategory, modelPolicy, preview, providerName, scopes);
266+
modelName, modelPickerCategory, modelPickerPriceCategory, modelPolicy, preview, providerName, scopes, vendor);
209267
}
210268

211269
@Override
@@ -214,6 +272,7 @@ public String toString() {
214272
builder.append("modelFamily", modelFamily);
215273
builder.append("modelName", modelName);
216274
builder.append("id", id);
275+
builder.append("vendor", vendor);
217276
builder.append("modelPolicy", modelPolicy);
218277
builder.append("scopes", scopes);
219278
builder.append("preview", preview);
@@ -224,6 +283,7 @@ public String toString() {
224283
builder.append("degradationReason", degradationReason);
225284
builder.append("providerName", providerName);
226285
builder.append("modelPickerCategory", modelPickerCategory);
286+
builder.append("modelPickerPriceCategory", modelPickerPriceCategory);
227287
return builder.toString();
228288
}
229289

com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/utils/ModelUtilsTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import static org.junit.jupiter.api.Assertions.assertEquals;
77
import static org.junit.jupiter.api.Assertions.assertNotNull;
8+
import static org.junit.jupiter.api.Assertions.assertNull;
89
import static org.junit.jupiter.api.Assertions.assertTrue;
910

1011
import org.junit.jupiter.api.Test;
@@ -56,4 +57,23 @@ void testConvertByokModelToCopilotModel_withToolCallingCapability() {
5657
assertTrue(result.getScopes().contains(CopilotScope.CHAT_PANEL));
5758
assertTrue(result.getScopes().contains(CopilotScope.AGENT_PANEL));
5859
}
60+
61+
@Test
62+
void testConvertByokModelToCopilotModel_preservesTokenLimits() {
63+
ByokModel byokModel = new ByokModel();
64+
byokModel.setModelId("gpt-4.1");
65+
66+
ByokModelCapabilities capabilities = new ByokModelCapabilities();
67+
capabilities.setMaxInputTokens(128000);
68+
capabilities.setMaxOutputTokens(16000);
69+
byokModel.setModelCapabilities(capabilities);
70+
71+
CopilotModel result = ModelUtils.convertByokModelToCopilotModel(byokModel);
72+
73+
assertNotNull(result.getCapabilities());
74+
assertNotNull(result.getCapabilities().limits());
75+
assertNull(result.getCapabilities().limits().maxContextWindowTokens());
76+
assertEquals(128000, result.getCapabilities().limits().maxInputTokens());
77+
assertEquals(16000, result.getCapabilities().limits().maxOutputTokens());
78+
}
5979
}
274 Bytes
Loading
356 Bytes
Loading
272 Bytes
Loading
351 Bytes
Loading
271 Bytes
Loading
336 Bytes
Loading
262 Bytes
Loading
331 Bytes
Loading

0 commit comments

Comments
 (0)