From 3ff76b40ea7697d7b46cf287c6345c3bd1a83383 Mon Sep 17 00:00:00 2001 From: celeste Date: Mon, 24 Jul 2023 03:14:56 -0400 Subject: [PATCH] various improvements --- README.md | 13 ++++++------- main.ts | 28 ---------------------------- manifest.json | 2 +- package.json | 2 +- styles.css | 11 ++++++++++- views.ts | 22 ++++++++++++++-------- 6 files changed, 32 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index 4f706c3..19806cc 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,9 @@ This is a reimplementation of [Loom](https://github.com/socketteer/loom) as an O Loom is a recursively branching interface to GPT-3 and other language models; it is designed to be conducive to exploratory and experimental use of base models. The workflow primarily consists of this: you hit `Ctrl+Space` from a point in the text, and Loom generates `n` child nodes of the current node, where each child contains a different completion of the text leading up to the cursor. This is paired with a tree interface and settings panel in the right sidebar, as well as a pane containing the full text of the current node and its siblings. -Loom also works on canvas files, but it doesn't work *well*, and I don't plan to improve this in the near future. +Loom can request completions from the following providers: [Cohere](https://docs.cohere.ai/docs), [TextSynth](https://textsynth.com/documentation.html), [OpenAI](https://platform.openai.com/docs/introduction), and [Azure OpenAI Service](https://learn.microsoft.com/en-us/azure/ai-services/openai). It can also request completions from implementations of [openai-cd2-proxy](https://github.com/cosmicoptima/openai-cd2-proxy), in which case you must provide the base URL in the Loom tab in Settings. -Loom can request completions from the following providers: [Cohere](https://docs.cohere.ai/docs), [TextSynth](https://textsynth.com/documentation.html), and [OpenAI](https://platform.openai.com/docs/introduction). It can also request completions from implementations of [openai-cd2-proxy](https://github.com/cosmicoptima/openai-cd2-proxy), in which case you must provide the base URL in the Loom tab in Settings. - -If you are interested in funding development of Loom(sidian), you can **[support me on Patreon](https://patreon.com/parafactual)**; I would then be able to devote more time to this and other independent projects. +If you are interested in funding this plugin's development, you can **[support me on Patreon](https://patreon.com/parafactual)**; I would then be able to devote more time to this and other independent projects. **If you are new to Obsidian:** if you want to see the tree interface, make sure to open the right sidebar using the button on the top right, or using `Ctrl+P` then `Toggle right sidebar`. Once you've done that, go to the Loom tab, which is signified by a network icon. @@ -20,6 +18,7 @@ If you are interested in funding development of Loom(sidian), you can **[support - generate siblings - `Ctrl+Shift+Space` - split at point - `Alt+c` - delete (current node) - `Alt+Backspace` +- merge (current node) with parent - `Alt+m` Navigation: - switch to next sibling - `Alt+Down` @@ -30,21 +29,21 @@ Navigation: In the editor: - `Shift+click` on the text corresponding to a node to switch to it -**How to install** (until Loom is added to the Obsidian store)**:** +**Loom can be installed in the Obsidian store.** If you don't want to do that: 1. Go to the latest release under the "Releases" subheading on the right 2. Download the zip file under "Assets" 3. Unzip the file you downloaded in `[path to vault]/.obsidian/plugins`, creating the `plugins` directory if necessary 4. Go to the "Community plugins" tab in Obsidian settings, then enable "Loom" -Alternatively, you can build from source, which makes it easy to update: +Alternatively, you can build Loom from source: 1. Clone this repository (`git clone https://github.com/cosmicoptima/loom`) in `[path to vault]/.obsidian/plugins`, creating the `plugins` directory if necessary 2. Run the following: `cd loom; npm i; npm run build` 3. Go to the "Community plugins" tab in Obsidian settings, then enable "Loom" 4. To update, go to the repository and `git pull; npm i; npm run build`, then disable and re-enable Loom -**If you are using MacOS:** a few hotkeys -- `Alt+n`, `Alt+c` and `Alt+e` -- are bound to special characters. You can either: +**If you are using MacOS:** a few hotkeys -- `Alt+c` and `Alt+m` -- are bound to special characters. You can either: 1. Disable MacOS's special character shortcuts, as explained here: https://superuser.com/questions/941286/disable-default-option-key-binding 2. Rebind the Loom hotkeys you want to use in the Hotkeys tab in Settings diff --git a/main.ts b/main.ts index 84ac54d..6495616 100644 --- a/main.ts +++ b/main.ts @@ -1442,22 +1442,6 @@ class LoomSettingTab extends PluginSettingTab { method2.createEl("kbd", { text: "Loom: Open Loom pane" }); method2.createEl("span", { text: " command." }); - new Setting(containerEl).setName("Provider").addDropdown((dropdown) => { - dropdown.addOption("cohere", "Cohere"); - dropdown.addOption("textsynth", "TextSynth"); - dropdown.addOption("ocp", "OpenAI code-davinci-002 proxy"); - dropdown.addOption("openai", "OpenAI (Completion)"); - dropdown.addOption("openai-chat", "OpenAI (Chat)"); - dropdown.addOption("azure", "Azure (Completion)"); - dropdown.addOption("azure-chat", "Azure (Chat)"); - dropdown.setValue(this.plugin.settings.provider); - dropdown.onChange(async (value) => { - if (PROVIDERS.find((provider) => provider === value)) - this.plugin.settings.provider = value; - await this.plugin.save(); - }); - }); - const apiKeySetting = (name: string, key: LoomSettingStringKey) => { new Setting(containerEl) .setName(`${name} API key`) @@ -1489,10 +1473,6 @@ class LoomSettingTab extends PluginSettingTab { const idSetting = (name: string, key: LoomSettingKey) => setting(name, key, (value) => value, (text) => text); - const intSetting = (name: string, key: LoomSettingKey) => - setting(name, key, (value) => value.toString(), (text) => parseInt(text)); - const floatSetting = (name: string, key: LoomSettingKey) => - setting(name, key, (value) => value.toString(), (text) => parseFloat(text)); apiKeySetting("Cohere", "cohereApiKey"); apiKeySetting("TextSynth", "textsynthApiKey"); @@ -1525,13 +1505,5 @@ class LoomSettingTab extends PluginSettingTab { idSetting("Default passage separator", "defaultPassageSeparator"); idSetting("Default passage frontmatter", "defaultPassageFrontmatter"); - - idSetting("Model", "model"); - intSetting("Length (in tokens)", "maxTokens"); - floatSetting("Temperature", "temperature"); - floatSetting("Top p", "topP"); - floatSetting("Frequency penalty", "frequencyPenalty"); - floatSetting("Presence penalty", "presencePenalty"); - floatSetting("Number of completions", "n"); } } diff --git a/manifest.json b/manifest.json index 2fa0c08..df6f135 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "loom", "name": "Loom", - "version": "1.15.0", + "version": "1.15.1", "minAppVersion": "0.15.0", "description": "Loom in Obsidian", "author": "celeste", diff --git a/package.json b/package.json index fe1e93a..59dd490 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-loom", - "version": "1.15.0", + "version": "1.15.1", "description": "Loom in Obsidian", "main": "main.js", "scripts": { diff --git a/styles.css b/styles.css index 8b404ab..728cc89 100644 --- a/styles.css +++ b/styles.css @@ -71,6 +71,10 @@ body { margin-bottom: 0.8em; } +.loom__search-bar-no-results { + background-color: rgba(var(--background-modifier-error-rgb), 0.2) !important; +} + /* settings */ .loom__settings { @@ -182,9 +186,14 @@ body { .loom__node-button { display: inline-flex !important; - margin-left: 0.1em; + margin-left: -0.025em; + padding: 0.1em 0.075em; + border-radius: 0.2em; --icon-size: 1.1rem; } +.loom__node-button:hover { + background-color: var(--nav-item-background-active); +} .loom__node-footer { color: var(--text-faint); diff --git a/views.ts b/views.ts index 67320c5..ed2c017 100644 --- a/views.ts +++ b/views.ts @@ -156,12 +156,17 @@ export class LoomView extends ItemView { const searchBar = container.createEl("input", { cls: "loom__search-bar", value: state?.searchTerm || "", - attr: { type: "text", placeholder: "Search..." }, + attr: { type: "text", placeholder: "Search" }, }); searchBar.addEventListener("input", () => { const state = this.getNoteState(); this.app.workspace.trigger("loom:search", searchBar.value); - if (state) this.renderTree(this.tree, state); + if (state) { + this.renderTree(this.tree, state); + if (Object.values(state.nodes).every((node) => node.searchResultState === "none")) + searchBar.addClass("loom__search-bar-no-results"); + else searchBar.removeClass("loom__search-bar-no-results"); + } }); } @@ -259,8 +264,10 @@ export class LoomView extends ItemView { cls: "tree-item-self loom__tree-header" }); let headerText; - if (state.searchTerm) headerText = "Search results"; - else if (state.hoisted.length > 0) headerText = "Hoisted node"; + if (state.searchTerm) { + if (state.hoisted.length > 0) headerText = "Search results under hoisted node"; + else headerText = "Search results"; + } else if (state.hoisted.length > 0) headerText = "Hoisted node"; else headerText = "All nodes"; treeHeader.createSpan({ cls: "tree-item-inner loom__tree-header-text", @@ -345,7 +352,7 @@ export class LoomView extends ItemView { .filter(([, node]) => node.parentId === null) const deletable = rootNodes.length !== 1 || rootNodes[0][0] !== id; - const showMenu = () => { + const showMenu = (event) => { const menu = new Menu(); const menuItem = (name: string, icon: string, callback: () => void) => @@ -388,13 +395,12 @@ export class LoomView extends ItemView { selfArgMenuItem("Delete", "trash", "loom:delete"); } - const rect = nodeContainer.getBoundingClientRect(); - menu.showAtPosition({ x: rect.right, y: rect.top }); + menu.showAtMouseEvent(event); } nodeContainer.addEventListener("contextmenu", (event) => { event.preventDefault(); - showMenu(); + showMenu(event); }); // add buttons on hover