From 88d67093116f0ff36b60cc8726461c94e32ff1b7 Mon Sep 17 00:00:00 2001 From: celeste Date: Tue, 21 Mar 2023 12:19:11 -0700 Subject: [PATCH] add top p controls --- main.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/main.ts b/main.ts index 9d3e1f6..6f5ccf1 100644 --- a/main.ts +++ b/main.ts @@ -27,6 +27,7 @@ interface LoomSettings { model: string; maxTokens: number; temperature: number; + topP: number; n: number; showSettings: boolean; @@ -41,6 +42,7 @@ const DEFAULT_SETTINGS: LoomSettings = { model: "code-davinci-002", maxTokens: 60, temperature: 1, + topP: 1, n: 5, showSettings: false, @@ -865,6 +867,7 @@ export default class LoomPlugin extends Plugin { max_tokens: this.settings.maxTokens, n: this.settings.n, temperature: this.settings.temperature, + top_p: this.settings.topP, })).data.choices.map((choice) => choice.message?.content); } else { completions = ( @@ -874,6 +877,7 @@ export default class LoomPlugin extends Plugin { max_tokens: this.settings.maxTokens, n: this.settings.n, temperature: this.settings.temperature, + top_p: this.settings.topP, }) ).data.choices.map((choice) => choice.text); } @@ -1235,6 +1239,14 @@ class LoomView extends ItemView { "number", (value) => parseFloat(value) ); + setting( + "Top p", + "loom-top-p", + "topP", + String(settings.topP), + "number", + (value) => parseFloat(value) + ); setting( "Number of completions", "loom-n", @@ -1636,6 +1648,15 @@ class LoomSettingTab extends PluginSettingTab { }) ); + new Setting(containerEl).setName("Top p").addText((text) => + text + .setValue(this.plugin.settings.topP.toString()) + .onChange(async (value) => { + this.plugin.settings.topP = parseFloat(value); + await this.plugin.save(); + }) + ); + new Setting(containerEl).setName("Number of completions").addText((text) => text .setValue(this.plugin.settings.n.toString())