mirror of
https://github.com/cosmicoptima/loom.git
synced 2026-07-22 07:40:25 +00:00
add top p controls
This commit is contained in:
parent
0589820878
commit
88d6709311
1 changed files with 21 additions and 0 deletions
21
main.ts
21
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())
|
||||
|
|
|
|||
Loading…
Reference in a new issue