From f15cc5a7e8f6b87554c8131b482dd3ae84d84c12 Mon Sep 17 00:00:00 2001 From: Chris Lettieri Date: Mon, 13 Oct 2025 14:51:50 -0400 Subject: [PATCH] add new openai models and field to override --- src/main.ts | 29 ++++++++++++++++++----------- src/services/openai-service.ts | 10 ++++++---- src/types/settings.ts | 4 ++++ src/ui/settings-tab.ts | 26 ++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/src/main.ts b/src/main.ts index df4767a..8676f97 100644 --- a/src/main.ts +++ b/src/main.ts @@ -126,11 +126,18 @@ export default class OpenAugiPlugin extends Plugin { this.addSettingTab(new OpenAugiSettingTab(this.app, this)); } + /** + * Get the configured model (custom override or default) + */ + private getConfiguredModel(): string { + return this.settings.customModelOverride.trim() || this.settings.defaultModel; + } + /** * Initialize services with current settings */ private initializeServices(): void { - this.openAIService = new OpenAIService(this.settings.apiKey); + this.openAIService = new OpenAIService(this.settings.apiKey, this.getConfiguredModel()); this.fileService = new FileService( this.app, this.settings.summaryFolder, @@ -186,8 +193,8 @@ export default class OpenAugiPlugin extends Plugin { // Display character and token count new Notice(`Processing transcript: ${file.basename}\nCharacters: ${content.length}\nEst. Tokens: ${estimateTokens(content)}`); - // Update openAIService with latest API key - this.openAIService = new OpenAIService(this.settings.apiKey); + // Update openAIService with latest API key and model + this.openAIService = new OpenAIService(this.settings.apiKey, this.getConfiguredModel()); // Parse transcript const parsedData = await this.openAIService.parseTranscript(content); @@ -247,8 +254,8 @@ export default class OpenAugiPlugin extends Plugin { return; } - // Update services with latest API key - this.openAIService = new OpenAIService(this.settings.apiKey); + // Update services with latest API key and model + this.openAIService = new OpenAIService(this.settings.apiKey, this.getConfiguredModel()); this.distillService = new DistillService( this.app, this.openAIService, @@ -367,8 +374,8 @@ export default class OpenAugiPlugin extends Plugin { // Show loading indicator this.loadingIndicator?.show('Discovering recent activity...'); - // Update services with latest API key - this.openAIService = new OpenAIService(this.settings.apiKey); + // Update services with latest API key and model + this.openAIService = new OpenAIService(this.settings.apiKey, this.getConfiguredModel()); this.distillService = new DistillService( this.app, this.openAIService, @@ -753,8 +760,8 @@ ${allFiles.map(f => `- [[${f.basename}]]`).join('\n')}`; try { this.loadingIndicator?.show('Distilling content...'); - // Update services with latest API key - this.openAIService = new OpenAIService(this.settings.apiKey); + // Update services with latest API key and model + this.openAIService = new OpenAIService(this.settings.apiKey, this.getConfiguredModel()); this.distillService = new DistillService( this.app, this.openAIService, @@ -800,8 +807,8 @@ ${allFiles.map(f => `- [[${f.basename}]]`).join('\n')}`; try { this.loadingIndicator?.show('Publishing content...'); - // Update services with latest API key - this.openAIService = new OpenAIService(this.settings.apiKey); + // Update services with latest API key and model + this.openAIService = new OpenAIService(this.settings.apiKey, this.getConfiguredModel()); // Call publish API const publishedContent = await this.openAIService.publishContent( diff --git a/src/services/openai-service.ts b/src/services/openai-service.ts index e67dabf..109a803 100644 --- a/src/services/openai-service.ts +++ b/src/services/openai-service.ts @@ -15,9 +15,11 @@ function estimateTokens(text: string): number { */ export class OpenAIService { private apiKey: string; + private model: string; - constructor(apiKey: string) { + constructor(apiKey: string, model: string) { this.apiKey = apiKey; + this.model = model; } /** @@ -130,7 +132,7 @@ export class OpenAIService { 'Authorization': `Bearer ${this.apiKey}` }, body: JSON.stringify({ - model: 'gpt-4.1-2025-04-14', + model: this.model, messages: [{ role: 'user', content: prompt }], temperature: 0.2, max_tokens: 32768, @@ -283,7 +285,7 @@ export class OpenAIService { 'Authorization': `Bearer ${this.apiKey}` }, body: JSON.stringify({ - model: 'gpt-4.1-2025-04-14', + model: this.model, messages: [{ role: 'user', content: prompt }], temperature: 0.2, max_tokens: 32768, @@ -450,7 +452,7 @@ Return a single markdown blog post, ready to publish.`; 'Authorization': `Bearer ${this.apiKey}` }, body: JSON.stringify({ - model: 'gpt-4.1-2025-04-14', + model: this.model, messages: [{ role: 'user', content: prompt }], temperature: 0.7, // Higher temperature for more creative output max_tokens: 32768 diff --git a/src/types/settings.ts b/src/types/settings.ts index b1a2d5d..ec3f4d4 100644 --- a/src/types/settings.ts +++ b/src/types/settings.ts @@ -15,6 +15,8 @@ export interface ContextGatheringDefaults { export interface OpenAugiSettings { apiKey: string; + defaultModel: string; + customModelOverride: string; summaryFolder: string; notesFolder: string; promptsFolder: string; @@ -27,6 +29,8 @@ export interface OpenAugiSettings { export const DEFAULT_SETTINGS: OpenAugiSettings = { apiKey: '', + defaultModel: 'gpt-5', + customModelOverride: '', summaryFolder: 'OpenAugi/Summaries', notesFolder: 'OpenAugi/Notes', promptsFolder: 'OpenAugi/Prompts', diff --git a/src/ui/settings-tab.ts b/src/ui/settings-tab.ts index d915bf5..1e3d219 100644 --- a/src/ui/settings-tab.ts +++ b/src/ui/settings-tab.ts @@ -34,6 +34,32 @@ export class OpenAugiSettingTab extends PluginSettingTab { } }) ); + + new Setting(containerEl) + .setName('OpenAI Model') + .setDesc('Select the OpenAI model to use for processing') + .addDropdown(dropdown => dropdown + .addOption('gpt-5', 'GPT-5') + .addOption('gpt-5-mini', 'GPT-5 Mini') + .addOption('gpt-5-nano', 'GPT-5 Nano') + .setValue(this.plugin.settings.defaultModel) + .onChange(async (value) => { + this.plugin.settings.defaultModel = value; + await this.plugin.saveSettings(); + }) + ); + + new Setting(containerEl) + .setName('Custom Model Override (Optional)') + .setDesc('Specify any OpenAI model name to override the selection above. Leave empty to use the selected model.') + .addText(text => text + .setPlaceholder('e.g., gpt-4o-2024-11-20') + .setValue(this.plugin.settings.customModelOverride) + .onChange(async (value) => { + this.plugin.settings.customModelOverride = value; + await this.plugin.saveSettings(); + }) + ); new Setting(containerEl) .setName('Summaries folder')