Skip to content

Commit 560cefe

Browse files
authored
Only requesting requesty models if requesty api key is set (RooCodeInc#2028)
* changeset * changeset
1 parent 12dbf15 commit 560cefe

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

.changeset/thirty-hairs-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
only fetching requesty models if api key set

src/core/webview/ClineProvider.ts

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -540,32 +540,35 @@ export class ClineProvider implements vscode.WebviewViewProvider {
540540
const { telemetrySetting } = state
541541
const isOptedIn = telemetrySetting === "enabled"
542542
telemetryService.updateTelemetryState(isOptedIn)
543-
})
544543

545-
// post last cached models in case the call to endpoint fails
546-
this.readDynamicProviderModels(GlobalFileNames.requestyModels).then((requestyModels) => {
547-
if (requestyModels) {
548-
this.postMessageToWebview({
549-
type: "requestyModels",
550-
requestyModels,
544+
// only fetch requesty api key if api key is set
545+
if (state.apiConfiguration?.requestyApiKey) {
546+
// post last cached models in case the call to endpoint fails
547+
this.readDynamicProviderModels(GlobalFileNames.requestyModels).then((requestyModels) => {
548+
if (requestyModels) {
549+
this.postMessageToWebview({
550+
type: "requestyModels",
551+
requestyModels,
552+
})
553+
}
551554
})
552-
}
553-
})
554555

555-
// gui relies on model info to be up-to-date to provide the most accurate pricing, so we need to fetch the latest details on launch.
556-
// we do this for all users since many users switch between api providers and if they were to switch back to openrouter it would be showing outdated model info if we hadn't retrieved the latest at this point
557-
// (see normalizeApiConfiguration > openrouter)
558-
this.refreshRequestyModels().then(async (requestyModels) => {
559-
if (requestyModels) {
560-
// update model info in state (this needs to be done here since we don't want to update state while settings is open, and we may refresh models there)
561-
const { apiConfiguration } = await this.getState()
562-
if (apiConfiguration.requestyModelId) {
563-
await this.updateGlobalState(
564-
"requestyModelInfo",
565-
requestyModels[apiConfiguration.requestyModelId],
566-
)
567-
await this.postStateToWebview()
568-
}
556+
// gui relies on model info to be up-to-date to provide the most accurate pricing, so we need to fetch the latest details on launch.
557+
// we do this for all users since many users switch between api providers and if they were to switch back to openrouter it would be showing outdated model info if we hadn't retrieved the latest at this point
558+
// (see normalizeApiConfiguration > openrouter)
559+
this.refreshRequestyModels().then(async (requestyModels) => {
560+
if (requestyModels) {
561+
// update model info in state (this needs to be done here since we don't want to update state while settings is open, and we may refresh models there)
562+
const { apiConfiguration } = await this.getState()
563+
if (apiConfiguration.requestyModelId) {
564+
await this.updateGlobalState(
565+
"requestyModelInfo",
566+
requestyModels[apiConfiguration.requestyModelId],
567+
)
568+
await this.postStateToWebview()
569+
}
570+
}
571+
})
569572
}
570573
})
571574

0 commit comments

Comments
 (0)