feat: Add extra parameters support for OpenAI compatible providers

Merge pull request #13 from el95149/feature/openai_compatible_extra_parameters
This commit is contained in:
Ahmet Ildirim 2026-04-11 21:49:32 +02:00 committed by GitHub
commit 9cdcd681ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 28 additions and 2 deletions

4
package-lock.json generated
View file

@ -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",

View file

@ -32,6 +32,7 @@ export class OpenAICompatibleProvider implements Provider {
],
temperature: options.temperature,
stream: true,
...this.settings.extraParams,
}, { signal: this.abortcontroller.signal });
let completion = "";

View file

@ -9,4 +9,5 @@ export interface OpenAICompatibleSettings {
models: string[];
configured: boolean;
temperature_range: { min: number; max: number };
extraParams: Record<string, unknown>;
}

View file

@ -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() {

View file

@ -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,