Adds dynamic Claude model fetching and management #1
+8
-5
@@ -245,15 +245,18 @@ export class FreewritingPromptsSettingTab extends PluginSettingTab {
|
|||||||
const modelExists = this.availableModels.some(m => m.id === currentModel);
|
const modelExists = this.availableModels.some(m => m.id === currentModel);
|
||||||
if (modelExists) {
|
if (modelExists) {
|
||||||
this.modelDropdown.setValue(currentModel);
|
this.modelDropdown.setValue(currentModel);
|
||||||
} else if (this.availableModels.length > 0) {
|
} else {
|
||||||
// Fall back to first available model if current one is gone
|
// Fall back to first available model if current one is gone
|
||||||
this.plugin.settings.model = this.availableModels[0].id;
|
const fallbackModel = this.availableModels[0];
|
||||||
this.modelDropdown.setValue(this.availableModels[0].id);
|
if (fallbackModel) {
|
||||||
new Notice('Your selected model is no longer available. Defaulting to ' + this.availableModels[0].displayName);
|
this.modelDropdown.setValue(fallbackModel.id);
|
||||||
|
this.plugin.settings.model = fallbackModel.id;
|
||||||
|
new Notice('Your selected model is no longer available. Defaulting to ' + fallbackModel.displayName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save updated cache
|
// Persist any selection changes
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error refreshing models:', error);
|
console.error('Error refreshing models:', error);
|
||||||
|
|||||||
Reference in new issue
Block a user