Skip to content

Commit a2be913

Browse files
committed
Recommend Sonnet and Haiku 4.5
1 parent 0e7342f commit a2be913

File tree

2 files changed

+46
-37
lines changed

2 files changed

+46
-37
lines changed

src/assistant/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ You can also ask me to explain the code in your Shiny app, or to help you with a
573573
) {
574574
// We get here if the model is not enabled.
575575
stream.markdown(
576-
`The requested model, ${request.model.name} is not enabled. You can enable it at [https://github.com/settings/copilot](https://github.com/settings/copilot). Scroll down to **Anthropic Claude 4 Sonnet in Copilot** and set it to **Enable**.\n\n`
576+
`The requested model, ${request.model.name} is not enabled. You can enable it at [https://github.com/settings/copilot](https://github.com/settings/copilot).\n\n`
577577
);
578578
stream.markdown(
579579
`Or you can send another message in this chat without \`@shiny\`, like \`"Hello"\`, and Copilot will ask you if you want to enable ${request.model.name}. After you enable it, remember to start the next message with \`@shiny\` again.\n\n`

src/assistant/llm-selection.ts

Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,57 @@
11
import type * as vscode from "vscode";
2-
import { isPositron } from "../extension-api-utils/extensionHost";
32

4-
export function checkUsingDesiredModel(model: vscode.LanguageModelChat) {
5-
// In older versions of VS Code, the model names were like "Claude 3.5
6-
// Sonnet", but in newer versions, they are like "Claude Sonnet 3.5".
7-
// In Positron as of this writing, the model names are like "Claude 3.5
8-
// Sonnet".
9-
if (model.name.match(/claude .*sonnet/i)) {
10-
return true;
11-
}
3+
/**
4+
* Returns the list of model names we accept (won't show warning for).
5+
* Includes both orderings ("Sonnet 4" and "4 Sonnet") to handle variations
6+
* across different platforms and versions.
7+
*/
8+
function getAcceptedModelNames(): string[] {
9+
return [
10+
"Claude Sonnet 4.5",
11+
"Claude 4.5 Sonnet",
12+
"Claude Haiku 4.5",
13+
"Claude 4.5 Haiku",
14+
"Claude Sonnet 4",
15+
"Claude 4 Sonnet",
16+
"Claude Haiku 4",
17+
"Claude 4 Haiku",
18+
];
19+
}
20+
21+
/**
22+
* Returns the list of model names we suggest to users.
23+
* Always uses "Sonnet 4" ordering.
24+
*/
25+
function getSuggestedModelNames(): string[] {
26+
return ["Claude Sonnet 4.5", "Claude Haiku 4.5"];
27+
}
1228

13-
return false;
29+
export function checkUsingDesiredModel(model: vscode.LanguageModelChat) {
30+
const acceptedModels = getAcceptedModelNames();
31+
return acceptedModels.some(
32+
(acceptedModel) =>
33+
model.name.toLowerCase() === acceptedModel.toLowerCase()
34+
);
1435
}
1536

1637
export function displayDesiredModelSuggestion(
1738
modelName: string,
1839
stream: vscode.ChatResponseStream
1940
) {
20-
if (isPositron()) {
21-
// The text displays much more quickly if we call markdown() twice instead
22-
// of just once.
23-
stream.markdown(
24-
`It looks like you are using **${modelName}** for Copilot. `
25-
);
26-
stream.markdown(
27-
`For best results with \`@shiny\`, please switch to **${desiredModelName()}**.\n\n`
28-
);
29-
} else {
30-
// VS Code
31-
// The text displays much more quickly if we call markdown() twice instead
32-
// of just once.
33-
stream.markdown(
34-
`It looks like you are using **${modelName}** for Copilot. `
35-
);
36-
stream.markdown(
37-
`For best results with \`@shiny\`, please switch to **${desiredModelName()}**.\n\n`
38-
);
39-
}
41+
const suggestedModels = getSuggestedModelNames();
42+
const suggestionText = suggestedModels.join(" or ");
43+
44+
// The text displays much more quickly if we call markdown() twice instead
45+
// of just once.
46+
stream.markdown(
47+
`It looks like you are using **${modelName}** for Copilot. `
48+
);
49+
stream.markdown(
50+
`For best results with \`@shiny\`, please switch to **${suggestionText}**.\n\n`
51+
);
4052

4153
stream.button({
42-
title: `I'll switch to ${desiredModelName()}`,
54+
title: `I'll switch to a recommended model`,
4355
command: "shiny.assistant.continueAfterDesiredModelSuggestion",
4456
arguments: [true],
4557
});
@@ -51,9 +63,6 @@ export function displayDesiredModelSuggestion(
5163
}
5264

5365
export function desiredModelName() {
54-
if (isPositron()) {
55-
return "Claude 4 Sonnet";
56-
} else {
57-
return "Claude Sonnet 4";
58-
}
66+
const suggestedModels = getSuggestedModelNames();
67+
return suggestedModels.join(" or ");
5968
}

0 commit comments

Comments
 (0)