Skip to content

Commit 30e3d0a

Browse files
authored
Assistant: Use user selected model (#9227)
Addresses #9226. I think this broke when the Code OSS language model proposed API changed to introduce `prepareLanguageModelChat()`. These changes essentially defer selection of the model ID until the very last second in e.g. `provideLanguageModelChatResponse()` and other methods, rather than trying to store a specific model ID on a class property such as `this._config` or `this.model`, since a single language model provider instance can now handle multiple model IDs. ## QA * Open Positron * Open Assistant, select a non-default model for your provider, e.g. Claude 4 Opus. * Send a request, watching the Assistant log output pane. * Ensure that the right model is selected by watching the model ID reported in the logs. * Repeat for the Anthropic and the AWS Bedrock providers, to cover both the Anthropic SDK and Vercel AI SDK code paths. * We should probably also check the `maxOutputTokens` config setting still works, since I've had to tweak that code. <img width="950" height="63" alt="Screenshot 2025-08-29 at 14 50 24" src="https://github.com/user-attachments/assets/82585446-7dac-46cd-9255-fc187647ddb4" /> <img width="945" height="59" alt="Screenshot 2025-08-29 at 14 50 51" src="https://github.com/user-attachments/assets/364d1270-9f03-44af-84de-d19d7ed63761" />
1 parent e3620e8 commit 30e3d0a

File tree

6 files changed

+152
-164
lines changed

6 files changed

+152
-164
lines changed

build/secrets/.secrets.baseline

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@
9090
{
9191
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
9292
},
93+
{
94+
"path": "detect_secrets.filters.common.is_baseline_file",
95+
"filename": "build/secrets/.secrets.baseline"
96+
},
9397
{
9498
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
9599
},
@@ -1051,7 +1055,7 @@
10511055
"filename": "extensions/positron-assistant/src/models.ts",
10521056
"hashed_secret": "ba10d824a2c4c13ce293171d14843c0f0043d039",
10531057
"is_verified": false,
1054-
"line_number": 819,
1058+
"line_number": 833,
10551059
"is_secret": false
10561060
}
10571061
],
@@ -1734,5 +1738,5 @@
17341738
}
17351739
]
17361740
},
1737-
"generated_at": "2025-08-25T17:39:02Z"
1741+
"generated_at": "2025-08-29T13:42:08Z"
17381742
}

extensions/positron-assistant/package-lock.json

Lines changed: 54 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extensions/positron-assistant/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@
575575
"@types/mocha": "^9.1.0",
576576
"@types/node": "^20",
577577
"@types/sinon": "^17.0.3",
578-
"ai": "^4.1.46",
578+
"ai": "^4.3.19",
579579
"eslint": "^9.13.0",
580580
"google-auth-library": "^9.15.1",
581581
"mocha": "^9.2.1",

extensions/positron-assistant/src/anthropic.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class AnthropicLanguageModel implements positron.ai.LanguageModelChatProv
128128
const anthropicMessages = toAnthropicMessages(messages);
129129

130130
const body: Anthropic.MessageStreamParams = {
131-
model: this._config.model,
131+
model: model.id,
132132
max_tokens: options.modelOptions?.maxTokens ?? this.maxOutputTokens,
133133
tools,
134134
tool_choice,
@@ -140,7 +140,7 @@ export class AnthropicLanguageModel implements positron.ai.LanguageModelChatProv
140140

141141
// Log request information - the request ID is only available upon connection.
142142
stream.on('connect', () => {
143-
log.info(`[anthropic] Start request ${stream.request_id} to ${this._config.model}: ${anthropicMessages.length} messages`);
143+
log.info(`[anthropic] Start request ${stream.request_id} to ${model.id}: ${anthropicMessages.length} messages`);
144144
if (log.logLevel <= vscode.LogLevel.Trace) {
145145
log.trace(`[anthropic] SEND messages.stream [${stream.request_id}]: ${JSON.stringify(body, null, 2)}`);
146146
} else {
@@ -280,7 +280,7 @@ export class AnthropicLanguageModel implements positron.ai.LanguageModelChatProv
280280
}
281281
}
282282
const result = await this._client.messages.countTokens({
283-
model: this._config.model,
283+
model: model.id,
284284
messages,
285285
});
286286
return result.input_tokens;

0 commit comments

Comments
 (0)