Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class CopilotModel {
private String modelFamily;
private String modelName;
private String id;
private String vendor;
private CopilotModelPolicy modelPolicy;
private List<String> scopes;
private boolean preview;
Expand All @@ -26,6 +27,7 @@ public class CopilotModel {
private String degradationReason;
private String providerName;
private String modelPickerCategory;
private String modelPickerPriceCategory;

/**
* Policy for the model.
Expand All @@ -52,27 +54,65 @@ public String toString() {
}
}

/**
* Capabilities limits for the model. All components are optional ({@code null} when the server does not provide a
* value), mirroring the {@code number | undefined} fields in the language-server schema.
*/
public record CopilotModelCapabilitiesLimits(Integer maxContextWindowTokens, Integer maxOutputTokens,
Integer maxInputTokens, Integer maxNonStreamingOutputTokens) {
@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this);
builder.append("maxContextWindowTokens", maxContextWindowTokens);
builder.append("maxOutputTokens", maxOutputTokens);
builder.append("maxInputTokens", maxInputTokens);
builder.append("maxNonStreamingOutputTokens", maxNonStreamingOutputTokens);
return builder.toString();
}
}

/**
* Capabilities for the model.
*/
public record CopilotModelCapabilities(CopilotModelCapabilitiesSupports supports) {
public record CopilotModelCapabilities(CopilotModelCapabilitiesSupports supports,
CopilotModelCapabilitiesLimits limits) {
@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this);
builder.append("supports", supports);
builder.append("limits", limits);
return builder.toString();
}
}

/**
* Per-token prices for the model, returned in USD.
*/
public record CopilotModelBillingTokenPrices(Double cachePrice, Double inputPrice, Double outputPrice,
Double tokenUnit) {
@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this);
builder.append("cachePrice", cachePrice);
builder.append("inputPrice", inputPrice);
builder.append("outputPrice", outputPrice);
builder.append("tokenUnit", tokenUnit);
return builder.toString();
}
}

/**
* Billing for the model.
*/
public record CopilotModelBilling(boolean isPremium, double multiplier) {
public record CopilotModelBilling(boolean isPremium, double multiplier, boolean tokenBasedBillingEnabled,
CopilotModelBillingTokenPrices tokenPrices) {
@Override
public String toString() {
ToStringBuilder builder = new ToStringBuilder(this);
builder.append("isPremium", isPremium);
builder.append("multiplier", multiplier);
builder.append("tokenBasedBillingEnabled", tokenBasedBillingEnabled);
builder.append("tokenPrices", tokenPrices);
return builder.toString();
}
}
Expand Down Expand Up @@ -101,6 +141,14 @@ public void setId(String id) {
this.id = id;
}

public String getVendor() {
return vendor;
}

public void setVendor(String vendor) {
this.vendor = vendor;
}

public CopilotModelPolicy getModelPolicy() {
return modelPolicy;
}
Expand Down Expand Up @@ -181,6 +229,14 @@ public void setModelPickerCategory(String modelPickerCategory) {
this.modelPickerCategory = modelPickerCategory;
}

public String getModelPickerPriceCategory() {
return modelPickerPriceCategory;
}

public void setModelPickerPriceCategory(String modelPickerPriceCategory) {
this.modelPickerPriceCategory = modelPickerPriceCategory;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
Expand All @@ -198,14 +254,16 @@ public boolean equals(Object obj) {
&& isChatDefault == other.isChatDefault && isChatFallback == other.isChatFallback
&& Objects.equals(modelFamily, other.modelFamily) && Objects.equals(modelName, other.modelName)
&& Objects.equals(modelPickerCategory, other.modelPickerCategory)
&& Objects.equals(modelPickerPriceCategory, other.modelPickerPriceCategory)
&& Objects.equals(modelPolicy, other.modelPolicy) && preview == other.preview
&& Objects.equals(providerName, other.providerName) && Objects.equals(scopes, other.scopes);
&& Objects.equals(providerName, other.providerName) && Objects.equals(scopes, other.scopes)
&& Objects.equals(vendor, other.vendor);
}

@Override
public int hashCode() {
return Objects.hash(billing, capabilities, degradationReason, id, isChatDefault, isChatFallback, modelFamily,
modelName, modelPickerCategory, modelPolicy, preview, providerName, scopes);
modelName, modelPickerCategory, modelPickerPriceCategory, modelPolicy, preview, providerName, scopes, vendor);
}

@Override
Expand All @@ -214,6 +272,7 @@ public String toString() {
builder.append("modelFamily", modelFamily);
builder.append("modelName", modelName);
builder.append("id", id);
builder.append("vendor", vendor);
builder.append("modelPolicy", modelPolicy);
builder.append("scopes", scopes);
builder.append("preview", preview);
Expand All @@ -224,6 +283,7 @@ public String toString() {
builder.append("degradationReason", degradationReason);
builder.append("providerName", providerName);
builder.append("modelPickerCategory", modelPickerCategory);
builder.append("modelPickerPriceCategory", modelPickerPriceCategory);
return builder.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -56,4 +57,23 @@ void testConvertByokModelToCopilotModel_withToolCallingCapability() {
assertTrue(result.getScopes().contains(CopilotScope.CHAT_PANEL));
assertTrue(result.getScopes().contains(CopilotScope.AGENT_PANEL));
}

@Test
void testConvertByokModelToCopilotModel_preservesTokenLimits() {
ByokModel byokModel = new ByokModel();
byokModel.setModelId("gpt-4.1");

ByokModelCapabilities capabilities = new ByokModelCapabilities();
capabilities.setMaxInputTokens(128000);
capabilities.setMaxOutputTokens(16000);
byokModel.setModelCapabilities(capabilities);

CopilotModel result = ModelUtils.convertByokModelToCopilotModel(byokModel);

assertNotNull(result.getCapabilities());
assertNotNull(result.getCapabilities().limits());
assertNull(result.getCapabilities().limits().maxContextWindowTokens());
assertEquals(128000, result.getCapabilities().limits().maxInputTokens());
assertEquals(16000, result.getCapabilities().limits().maxOutputTokens());
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,9 @@ public final class Messages extends NLS {
public static String chat_historyView_deleteIcon_tooltip;
public static String model_billing_multiplier_suffix;
public static String model_billing_multiplier_variable;
public static String model_tooltip_quota;
public static String model_hover_family;
public static String model_hover_contextSize;
public static String model_hover_contextWindow;
public static String model_hover_cost;
public static String model_hover_cost_premium;
public static String chat_actionBar_modePicker_Tooltip;
public static String chat_actionBar_modelPicker_Tooltip;
public static String context_window_title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,9 @@ newChat_cancelButton=Cancel
addToReference_addFile_title=Add File to Chat
addToReference_addFolder_title=Add Folder to Chat

model_tooltip_quota=Each chat message counts %s towards your request quota
model_hover_family=Family:
model_hover_cost=Cost:
model_hover_cost_premium=premium
model_hover_contextSize=Context Size:
model_hover_contextWindow=Context Window:
model_hover_cost=Cost:
chat_actionBar_modePicker_Tooltip=Set Agents
chat_actionBar_modelPicker_Tooltip=Pick Model{0}
context_window_title=Context Window
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ private void openHoverShell(DropdownItem item, Composite anchorItem) {
hoverShell = new Shell(shell, SWT.NO_TRIM | SWT.ON_TOP);
hoverShell.setData(CssConstants.CSS_ID_KEY, "dropdown-popup");
final Display display = hoverShell.getDisplay();
Color popupBg = CssConstants.getPopupBgColor(display);
hoverShell.setBackground(popupBg);
styleControl(hoverShell);
GridLayout layout = new GridLayout(1, false);
layout.marginWidth = ITEM_H_PADDING;
Expand All @@ -481,11 +483,14 @@ private void openHoverShell(DropdownItem item, Composite anchorItem) {

Composite hoverContent = new Composite(hoverShell, SWT.NONE);
hoverContent.setData(CssConstants.CSS_ID_KEY, "dropdown-popup");
hoverContent.setBackground(popupBg);
styleControl(hoverContent);
Comment thread
jdneo marked this conversation as resolved.
hoverContent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
GridLayout contentLayout = new GridLayout(1, false);
contentLayout.marginWidth = 0;
contentLayout.marginHeight = 0;
contentLayout.marginTop = ITEM_V_PADDING;
contentLayout.marginBottom = ITEM_V_PADDING;
hoverContent.setLayout(contentLayout);

item.getHoverProvider().configureHover(hoverContent, item);
Expand Down
Loading
Loading