Merge branch 'cosmicoptima:master' into master

This commit is contained in:
kneecaps 2023-05-24 15:03:12 -07:00 committed by GitHub
commit a6f44133d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 800 additions and 234 deletions

View file

@ -1,24 +1,49 @@
# loom(sidian)
**READ THE README IF YOU PLAN TO USE THIS PLUGIN. IT IS USEFUL**
This is a reimplementation of [Loom](https://github.com/socketteer/loom) as an Obsidian plugin, designed to be easier to use and more modular and extensible.
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.
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), 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 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.
Default hotkeys:
- `Ctrl+Space` - complete
- `Ctrl+Alt+n` - create child
- `Alt+n` - create sibling
- `Ctrl+Alt+c` - clone current node
- `Alt+c` - split in-range node at caret
**Default hotkeys:**
- `Alt+Backspace` - delete current node
- `Alt+Down` - switch to next sibling
- `Alt+Up` - switch to previous sibling
- `Alt+Left` - switch to parent
- `Alt+Right` - switch to (most recently visited) child
- `Alt+e` - collapse/expand current node
- generate - `Ctrl+Space`
- generate siblings - `Ctrl+Shift+Space`
- clone (current node) - `Ctrl+Alt+c`
- split at point - `Alt+c`
- delete (current node) - `Alt+Backspace`
Navigation:
- switch to next sibling - `Alt+Down`
- switch to previous sibling - `Alt+Up`
- switch to parent - `Alt+Left`
- switch to (most recently visited) child - `Alt+Right`
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)**:**
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:
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:

934
main.ts

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,11 @@
{
"id": "loom",
"name": "Loom",
"version": "1.0.0",
"version": "1.10.2",
"minAppVersion": "0.15.0",
"description": "Loom in Obsidian",
"author": "celeste",
"authorUrl": "https://celeste.exposed",
"fundingUrl": "https://www.patreon.com/parafactual",
"isDesktopOnly": true
}

14
package-lock.json generated
View file

@ -1,17 +1,18 @@
{
"name": "obsidian-loom",
"version": "0.1.0",
"version": "1.6.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "obsidian-loom",
"version": "0.1.0",
"version": "1.6.0",
"license": "MIT",
"dependencies": {
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.9.3",
"@types/lodash": "^4.14.191",
"azure-openai": "^0.9.4",
"cohere-ai": "^6.1.0",
"gpt3-tokenizer": "^1.1.5",
"openai": "^3.2.0",
@ -497,6 +498,15 @@
"follow-redirects": "^1.14.8"
}
},
"node_modules/azure-openai": {
"version": "0.9.4",
"resolved": "https://registry.npmjs.org/azure-openai/-/azure-openai-0.9.4.tgz",
"integrity": "sha512-7uii4ZInxzu2zjLg45PdvgOaw3ps18tEAw0Yux9mo8anX4PwnCMSS9xdlKNiNQyyEKPogvAcxH2PIufHXFLx6Q==",
"dependencies": {
"axios": "^0.26.0",
"form-data": "^4.0.0"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",

View file

@ -1,6 +1,6 @@
{
"name": "obsidian-loom",
"version": "0.1.0",
"version": "1.10.2",
"description": "Loom in Obsidian",
"main": "main.js",
"scripts": {
@ -27,6 +27,7 @@
"@codemirror/state": "^6.2.0",
"@codemirror/view": "^6.9.3",
"@types/lodash": "^4.14.191",
"azure-openai": "^0.9.4",
"cohere-ai": "^6.1.0",
"gpt3-tokenizer": "^1.1.5",
"openai": "^3.2.0",

View file

@ -145,6 +145,7 @@
overflow: hidden;
text-overflow: ellipsis;
padding: 0.35em 0 0.35em 0.6em;
flex-grow: 1;
}
.loom-node-bookmark {
@ -260,3 +261,31 @@
.loom-bct-hover {
background-color: var(--background-secondary);
}
.loom-sibling {
color: var(--nav-item-color);
font-size: 0.9em;
line-height: 1.3;
margin: 0.2em 0;
padding: 0.8em;
white-space: pre-wrap;
}
.loom-sibling:hover {
color: var(--nav-item-color-active);
}
.loom-sibling.is-active {
background-color: var(--nav-item-background-active);
color: var(--nav-item-color-active);
}
.loom-sibling-divider {
margin: 0;
}
.loom-sibling-ellipsis {
color: var(--text-faint);
margin-right: 0.3em;
}