diff --git a/package-lock.json b/package-lock.json index d1979ac..9799fd0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-inscribe", - "version": "1.1.5", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "obsidian-inscribe", - "version": "1.1.5", + "version": "1.2.0", "license": "MIT", "dependencies": { "@google/genai": "^1.41.0", diff --git a/src/providers/openai-compat/provider.ts b/src/providers/openai-compat/provider.ts index 4a3641d..5e7db60 100644 --- a/src/providers/openai-compat/provider.ts +++ b/src/providers/openai-compat/provider.ts @@ -32,6 +32,7 @@ export class OpenAICompatibleProvider implements Provider { ], temperature: options.temperature, stream: true, + ...this.settings.extraParams, }, { signal: this.abortcontroller.signal }); let completion = ""; diff --git a/src/providers/openai-compat/settings.ts b/src/providers/openai-compat/settings.ts index eb01567..58b7b02 100644 --- a/src/providers/openai-compat/settings.ts +++ b/src/providers/openai-compat/settings.ts @@ -9,4 +9,5 @@ export interface OpenAICompatibleSettings { models: string[]; configured: boolean; temperature_range: { min: number; max: number }; + extraParams: Record; } \ No newline at end of file diff --git a/src/settings/provider.ts b/src/settings/provider.ts index b50dd73..2bf317e 100644 --- a/src/settings/provider.ts +++ b/src/settings/provider.ts @@ -118,6 +118,29 @@ export class ProviderSettingsModal extends Modal { this.renderModelSettings(this.plugin.settings.providers.openai_compatible); this.renderConnectionStatus(this.plugin.settings.providers.openai_compatible); + + new Setting(contentEl) + .setName("Extra parameters") + .setDesc("Additional parameters passed to the API (JSON format). Example: {\"chat_template_kwargs\": {\"enable_thinking\": false}}") + .addTextArea((text) => { + text.inputEl.rows = 5; + text + .setValue(JSON.stringify(this.plugin.settings.providers.openai_compatible.extraParams, null, 2)) + .setPlaceholder("{}") + .onChange(async (value) => { + try { + const params = value.trim() ? JSON.parse(value) : {}; + if (typeof params === 'object' && params !== null && !Array.isArray(params)) { + this.plugin.settings.providers.openai_compatible.extraParams = params; + await this.plugin.saveSettings(); + } else { + new Notice("Extra parameters must be a valid JSON object"); + } + } catch (e) { + new Notice("Invalid JSON format"); + } + }); + }); } async renderGeminiSettings() { diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 69730ce..7c03e62 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -110,6 +110,7 @@ export const DEFAULT_SETTINGS: Settings = { models: ["gpt-4o", "gpt-4o-mini"], configured: false, temperature_range: { min: 0, max: 1 }, + extraParams: {}, }, gemini: { integration: ProviderType.GEMINI,