From aa1dba4992291a6103d81d38fc8987bd61b3bd55 Mon Sep 17 00:00:00 2001 From: ampdot Date: Wed, 17 Apr 2024 01:28:42 -0400 Subject: [PATCH] Improve compatibility with Together.ai --- main.ts | 26 +++++++++++++++----------- manifest.json | 2 +- package.json | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/main.ts b/main.ts index e4444c8..7cef94f 100644 --- a/main.ts +++ b/main.ts @@ -1423,6 +1423,18 @@ export default class LoomPlugin extends Plugin { if (!url.endsWith("/")) url += "/"; url = url.replace(/v1\//, ""); url += "v1/completions"; + let body: any = { + prompt, + model: getPreset(this.settings).model, // some providers such as OCP ignore model + max_tokens: this.settings.maxTokens, + n: this.settings.n, + temperature: this.settings.temperature, + top_p: this.settings.topP, + } + if (this.settings.frequencyPenalty !== 0) + body.frequency_penalty = this.settings.frequencyPenalty; + if (this.settings.presencePenalty !== 0) + body.presence_penalty = this.settings.presencePenalty; const response = await requestUrl({ url, @@ -1432,15 +1444,7 @@ export default class LoomPlugin extends Plugin { "Content-Type": "application/json", }, throw: false, - body: JSON.stringify({ - prompt, - max_tokens: this.settings.maxTokens, - n: this.settings.n, - temperature: this.settings.temperature, - top_p: this.settings.topP, - frequency_penalty: this.settings.frequencyPenalty, - presence_penalty: this.settings.presencePenalty, - }), + body: JSON.stringify(body), }); const result: CompletionResult = response.status === 200 @@ -1738,7 +1742,7 @@ class LoomSettingTab extends PluginSettingTab { }); restoreApiKeyDropdown.createEl("option", { text: "OpenAI", attr: { value: "openai" } }); - restoreApiKeyDropdown.createEl("option", { text: "OpenAI code-davinci-002 Proxy", attr: { value: "ocp" } }); + restoreApiKeyDropdown.createEl("option", { text: "OpenAI-compatible API", attr: { value: "ocp" } }); restoreApiKeyDropdown.createEl("option", { text: "Cohere", attr: { value: "cohere" } }); restoreApiKeyDropdown.createEl("option", { text: "TextSynth", attr: { value: "textsynth" } }); restoreApiKeyDropdown.createEl("option", { text: "Azure", attr: { value: "azure" } }); @@ -1836,7 +1840,7 @@ class LoomSettingTab extends PluginSettingTab { const options: Record = { cohere: "Cohere", textsynth: "TextSynth", - ocp: "OpenAI code-davinci-002 Proxy", + ocp: "OpenAI-compatible API", openai: "OpenAI", "openai-chat": "OpenAI (Chat)", azure: "Azure", diff --git a/manifest.json b/manifest.json index 6d12953..7e7f2cd 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "loom", "name": "Loom", - "version": "1.20.6", + "version": "1.20.7", "minAppVersion": "0.15.0", "description": "Loom in Obsidian", "author": "celeste", diff --git a/package.json b/package.json index dfcf574..4e8dfad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-loom", - "version": "1.20.6", + "version": "1.20.7", "description": "Loom in Obsidian", "main": "main.js", "scripts": {