mirror of
https://github.com/bitsofchris/openaugi-obsidian-plugin.git
synced 2026-07-22 05:46:42 +00:00
add new openai models and field to override
This commit is contained in:
parent
3db73cfba2
commit
f15cc5a7e8
4 changed files with 54 additions and 15 deletions
29
src/main.ts
29
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(
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue