Skip to content

Commit 05584ea

Browse files
authored
feat: Added model billing info to the popup hover (#1614)
1 parent 995c596 commit 05584ea

15 files changed

Lines changed: 291 additions & 70 deletions

File tree

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

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class CopilotModel {
1313
private String modelFamily;
1414
private String modelName;
1515
private String id;
16+
private String vendor;
1617
private CopilotModelPolicy modelPolicy;
1718
private List<String> scopes;
1819
private boolean preview;
@@ -48,27 +49,62 @@ public String toString() {
4849
}
4950
}
5051

52+
/**
53+
* Token limits for the model capabilities.
54+
*/
55+
public record CopilotModelCapabilitiesLimits(int maxInputTokens, int maxOutputTokens,
56+
int maxContextWindowTokens) {
57+
@Override
58+
public String toString() {
59+
ToStringBuilder builder = new ToStringBuilder(this);
60+
builder.append("maxInputTokens", maxInputTokens);
61+
builder.append("maxOutputTokens", maxOutputTokens);
62+
builder.append("maxContextWindowTokens", maxContextWindowTokens);
63+
return builder.toString();
64+
}
65+
}
66+
5167
/**
5268
* Capabilities for the model.
5369
*/
54-
public record CopilotModelCapabilities(CopilotModelCapabilitiesSupports supports) {
70+
public record CopilotModelCapabilities(CopilotModelCapabilitiesSupports supports,
71+
CopilotModelCapabilitiesLimits limits) {
5572
@Override
5673
public String toString() {
5774
ToStringBuilder builder = new ToStringBuilder(this);
5875
builder.append("supports", supports);
76+
builder.append("limits", limits);
77+
return builder.toString();
78+
}
79+
}
80+
81+
/**
82+
* Token prices for billing.
83+
*/
84+
public record CopilotModelBillingTokenPrices(double cachePrice, double inputPrice, double outputPrice,
85+
int tokenUnit) {
86+
@Override
87+
public String toString() {
88+
ToStringBuilder builder = new ToStringBuilder(this);
89+
builder.append("cachePrice", cachePrice);
90+
builder.append("inputPrice", inputPrice);
91+
builder.append("outputPrice", outputPrice);
92+
builder.append("tokenUnit", tokenUnit);
5993
return builder.toString();
6094
}
6195
}
6296

6397
/**
6498
* Billing for the model.
6599
*/
66-
public record CopilotModelBilling(boolean isPremium, double multiplier) {
100+
public record CopilotModelBilling(boolean isPremium, double multiplier,
101+
CopilotModelBillingTokenPrices tokenPrices) {
67102
@Override
68103
public String toString() {
69104
ToStringBuilder builder = new ToStringBuilder(this);
70105
builder.append("isPremium", isPremium);
71106
builder.append("multiplier", multiplier);
107+
builder.append("tokenPrices", tokenPrices);
72108
return builder.toString();
73109
}
74110
}
@@ -97,6 +133,14 @@ public void setId(String id) {
97133
this.id = id;
98134
}
99135

136+
public String getVendor() {
137+
return vendor;
138+
}
139+
140+
public void setVendor(String vendor) {
141+
this.vendor = vendor;
142+
}
143+
100144
public CopilotModelPolicy getModelPolicy() {
101145
return modelPolicy;
102146
}
@@ -186,13 +230,14 @@ public boolean equals(Object obj) {
186230
&& isChatDefault == other.isChatDefault && isChatFallback == other.isChatFallback
187231
&& Objects.equals(modelFamily, other.modelFamily) && Objects.equals(modelName, other.modelName)
188232
&& Objects.equals(modelPolicy, other.modelPolicy) && preview == other.preview
189-
&& Objects.equals(providerName, other.providerName) && Objects.equals(scopes, other.scopes);
233+
&& Objects.equals(providerName, other.providerName) && Objects.equals(scopes, other.scopes)
234+
&& Objects.equals(vendor, other.vendor);
190235
}
191236

192237
@Override
193238
public int hashCode() {
194239
return Objects.hash(billing, capabilities, degradationReason, id, isChatDefault, isChatFallback, modelFamily,
195-
modelName, modelPolicy, preview, providerName, scopes);
240+
modelName, modelPolicy, preview, providerName, scopes, vendor);
196241
}
197242

198243
@Override
@@ -201,6 +246,7 @@ public String toString() {
201246
builder.append("modelFamily", modelFamily);
202247
builder.append("modelName", modelName);
203248
builder.append("id", id);
249+
builder.append("vendor", vendor);
204250
builder.append("modelPolicy", modelPolicy);
205251
builder.append("scopes", scopes);
206252
builder.append("preview", preview);

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,23 @@ void testConvertByokModelToCopilotModel_withToolCallingCapability() {
5353
assertTrue(result.getScopes().contains(CopilotScope.CHAT_PANEL));
5454
assertTrue(result.getScopes().contains(CopilotScope.AGENT_PANEL));
5555
}
56+
57+
@Test
58+
void testConvertByokModelToCopilotModel_preservesTokenLimits() {
59+
ByokModel byokModel = new ByokModel();
60+
byokModel.setModelId("gpt-4.1");
61+
62+
ByokModelCapabilities capabilities = new ByokModelCapabilities();
63+
capabilities.setMaxInputTokens(128000);
64+
capabilities.setMaxOutputTokens(16000);
65+
byokModel.setModelCapabilities(capabilities);
66+
67+
CopilotModel result = ModelUtils.convertByokModelToCopilotModel(byokModel);
68+
69+
assertNotNull(result.getCapabilities());
70+
assertNotNull(result.getCapabilities().limits());
71+
assertEquals(-1, result.getCapabilities().limits().maxContextWindowTokens());
72+
assertEquals(128000, result.getCapabilities().limits().maxInputTokens());
73+
assertEquals(16000, result.getCapabilities().limits().maxOutputTokens());
74+
}
5675
}
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)