mirror of
https://github.com/ahmetildirim/obsidian-inscribe.git
synced 2026-07-22 05:44:10 +00:00
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:
commit
9cdcd681ac
5 changed files with 28 additions and 2 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export class OpenAICompatibleProvider implements Provider {
|
|||
],
|
||||
temperature: options.temperature,
|
||||
stream: true,
|
||||
...this.settings.extraParams,
|
||||
}, { signal: this.abortcontroller.signal });
|
||||
|
||||
let completion = "";
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ export interface OpenAICompatibleSettings {
|
|||
models: string[];
|
||||
configured: boolean;
|
||||
temperature_range: { min: number; max: number };
|
||||
extraParams: Record<string, unknown>;
|
||||
}
|
||||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue