mirror of
https://github.com/cosmicoptima/loom.git
synced 2026-07-22 07:40:25 +00:00
visibility checkboxes
This commit is contained in:
parent
7b04c99072
commit
e685ede86e
6 changed files with 107 additions and 18 deletions
|
|
@ -27,6 +27,7 @@ export interface LoomSettings {
|
||||||
modelPresets: ModelPreset<Provider>[];
|
modelPresets: ModelPreset<Provider>[];
|
||||||
modelPreset: number;
|
modelPreset: number;
|
||||||
|
|
||||||
|
visibility: Record<string, boolean>;
|
||||||
maxTokens: number;
|
maxTokens: number;
|
||||||
temperature: number;
|
temperature: number;
|
||||||
topP: number;
|
topP: number;
|
||||||
|
|
|
||||||
23
main.ts
23
main.ts
|
|
@ -54,6 +54,18 @@ const DEFAULT_SETTINGS: LoomSettings = {
|
||||||
modelPresets: [],
|
modelPresets: [],
|
||||||
modelPreset: -1,
|
modelPreset: -1,
|
||||||
|
|
||||||
|
visibility: {
|
||||||
|
"visibility": true,
|
||||||
|
"modelPreset": true,
|
||||||
|
"maxTokens": true,
|
||||||
|
"n": true,
|
||||||
|
"bestOf": false,
|
||||||
|
"temperature": true,
|
||||||
|
"topP": false,
|
||||||
|
"frequencyPenalty": false,
|
||||||
|
"presencePenalty": false,
|
||||||
|
"prepend": false,
|
||||||
|
},
|
||||||
maxTokens: 60,
|
maxTokens: 60,
|
||||||
temperature: 1,
|
temperature: 1,
|
||||||
topP: 1,
|
topP: 1,
|
||||||
|
|
@ -979,6 +991,17 @@ export default class LoomPlugin extends Plugin {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.registerEvent(
|
||||||
|
this.app.workspace.on(
|
||||||
|
// @ts-expect-error
|
||||||
|
"loom:set-visibility-setting",
|
||||||
|
(setting: string, value: boolean) => {
|
||||||
|
this.settings.visibility[setting] = value;
|
||||||
|
this.saveAndRender();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
this.registerEvent(
|
this.registerEvent(
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
this.app.workspace.on("loom:search", (term: string) => this.withFile((file) => {
|
this.app.workspace.on("loom:search", (term: string) => this.withFile((file) => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "loom",
|
"id": "loom",
|
||||||
"name": "Loom",
|
"name": "Loom",
|
||||||
"version": "1.19.4",
|
"version": "1.20.0",
|
||||||
"minAppVersion": "0.15.0",
|
"minAppVersion": "0.15.0",
|
||||||
"description": "Loom in Obsidian",
|
"description": "Loom in Obsidian",
|
||||||
"author": "celeste",
|
"author": "celeste",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "obsidian-loom",
|
"name": "obsidian-loom",
|
||||||
"version": "1.19.4",
|
"version": "1.20.0",
|
||||||
"description": "Loom in Obsidian",
|
"description": "Loom in Obsidian",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
20
styles.css
20
styles.css
|
|
@ -82,6 +82,26 @@ body {
|
||||||
margin-bottom: 0.3em;
|
margin-bottom: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loom__visibility {
|
||||||
|
margin-bottom: 0.7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loom__visibility-item {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 0.7em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loom__visibility-item-label {
|
||||||
|
font-size: var(--font-ui-small);
|
||||||
|
}
|
||||||
|
|
||||||
|
.loom__no-metavisibility {
|
||||||
|
color: var(--text-faint);
|
||||||
|
font-size: var(--font-ui-small);
|
||||||
|
margin: 0 0 0.5em 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
.loom__setting {
|
.loom__setting {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
||||||
77
views.ts
77
views.ts
|
|
@ -269,26 +269,69 @@ export class LoomView extends ItemView {
|
||||||
renderSettings(container: HTMLElement, settings: LoomSettings) {
|
renderSettings(container: HTMLElement, settings: LoomSettings) {
|
||||||
const settingsContainer = container.createDiv({ cls: "loom__settings" });
|
const settingsContainer = container.createDiv({ cls: "loom__settings" });
|
||||||
|
|
||||||
|
// visibility checkboxes
|
||||||
|
|
||||||
|
const visibilityContainer = settingsContainer.createDiv({ cls: "loom__visibility" });
|
||||||
|
|
||||||
|
const createCheckbox = (id: string, label: string, ellipsis: boolean = false) => {
|
||||||
|
const checkboxContainer = visibilityContainer.createSpan({ cls: "loom__visibility-item" });
|
||||||
|
const checkbox = checkboxContainer.createEl("input", {
|
||||||
|
attr: {
|
||||||
|
id: `loom__${id}-checkbox`,
|
||||||
|
checked: settings.visibility[id] ? "checked" : null
|
||||||
|
},
|
||||||
|
type: "checkbox",
|
||||||
|
});
|
||||||
|
checkbox.addEventListener("change", () =>
|
||||||
|
this.app.workspace.trigger("loom:set-visibility-setting", id, checkbox.checked)
|
||||||
|
);
|
||||||
|
|
||||||
|
const checkboxLabel = checkboxContainer.createEl("label", {
|
||||||
|
attr: { for: `loom__${id}-checkbox` },
|
||||||
|
cls: "loom__visibility-item-label",
|
||||||
|
text: label,
|
||||||
|
});
|
||||||
|
if (ellipsis && !settings.visibility.visibility) checkboxLabel.createSpan({
|
||||||
|
cls: "loom__no-metavisibility",
|
||||||
|
text: "...",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
createCheckbox("visibility", "These checkboxes", true);
|
||||||
|
if (settings.visibility["visibility"]) {
|
||||||
|
createCheckbox("modelPreset", "Model preset");
|
||||||
|
createCheckbox("maxTokens", "Length");
|
||||||
|
createCheckbox("n", "Number of completions");
|
||||||
|
createCheckbox("bestOf", "Best of");
|
||||||
|
createCheckbox("temperature", "Temperature");
|
||||||
|
createCheckbox("topP", "Top p");
|
||||||
|
createCheckbox("frequencyPenalty", "Frequency penalty");
|
||||||
|
createCheckbox("presencePenalty", "Presence penalty");
|
||||||
|
createCheckbox("prepend", "Prepend sequence");
|
||||||
|
}
|
||||||
|
|
||||||
// preset dropdown
|
// preset dropdown
|
||||||
|
|
||||||
const presetContainer = settingsContainer.createDiv({ cls: "loom__setting" });
|
if (settings.visibility["modelPreset"]) {
|
||||||
presetContainer.createEl("label", { text: "Model preset" });
|
const presetContainer = settingsContainer.createDiv({ cls: "loom__setting" });
|
||||||
const presetDropdown = presetContainer.createEl("select");
|
presetContainer.createEl("label", { text: "Model preset" });
|
||||||
|
const presetDropdown = presetContainer.createEl("select");
|
||||||
|
|
||||||
if (settings.modelPresets.length === 0)
|
if (settings.modelPresets.length === 0)
|
||||||
presetDropdown.createEl("option").createEl("i", { text: "[You have no presets. Go to Settings → Loom.]" });
|
presetDropdown.createEl("option").createEl("i", { text: "[You have no presets. Go to Settings → Loom.]" });
|
||||||
else {
|
else {
|
||||||
for (const i in settings.modelPresets) {
|
for (const i in settings.modelPresets) {
|
||||||
const preset = settings.modelPresets[i];
|
const preset = settings.modelPresets[i];
|
||||||
presetDropdown.createEl("option", {
|
presetDropdown.createEl("option", {
|
||||||
text: preset.name,
|
text: preset.name,
|
||||||
attr: { selected: settings.modelPreset === parseInt(i), value: i },
|
attr: { selected: settings.modelPreset === parseInt(i), value: i },
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
presetDropdown.addEventListener("change", () =>
|
||||||
|
this.app.workspace.trigger("loom:set-setting", "modelPreset", presetDropdown.value)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
presetDropdown.addEventListener("change", () =>
|
|
||||||
this.app.workspace.trigger("loom:set-setting", "modelPreset", presetDropdown.value)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// other settings
|
// other settings
|
||||||
|
|
@ -299,6 +342,8 @@ export class LoomView extends ItemView {
|
||||||
value: string,
|
value: string,
|
||||||
type: "string" | "int" | "float"
|
type: "string" | "int" | "float"
|
||||||
) => {
|
) => {
|
||||||
|
if (!settings.visibility[setting]) return;
|
||||||
|
|
||||||
const parsers = {
|
const parsers = {
|
||||||
"string": (value: string) => value,
|
"string": (value: string) => value,
|
||||||
"int": (value: string) => parseInt(value),
|
"int": (value: string) => parseInt(value),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue