Skip to content

Commit

Permalink
initial build
Browse files Browse the repository at this point in the history
  • Loading branch information
echo-saurav committed Nov 4, 2023
0 parents commit 0ec8b72
Show file tree
Hide file tree
Showing 19 changed files with 1,937 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
tab_width = 4
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/

main.js
23 changes: 23 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# vscode
.vscode

# Intellij
*.iml
.idea

# npm
node_modules

# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
main.js

# Exclude sourcemaps
*.map

# obsidian
data.json

# Exclude macOS Finder (System Explorer) View States
.DS_Store

package-lock.json
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tag-version-prefix=""
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# AI Note Suggestion Plugin for Obsidian

**AI Note Suggestion** plugin for Obsidian is designed to make your note-taking experience even more seamless. It harnesses the power of AI vector search using [Weaviate](https://weaviate.io/) to suggest similar and related notes as you type, reducing your dependency on traditional tagging systems. You can also filter notes by tags, giving you the flexibility you need.

## Features:
- **AI-Powered Suggestions:** The plugin suggests similar notes based on the content you're currently typing.
- **Related Notes:** Discover related notes that you might have missed, enhancing your note-taking context.
- **Tag Filtering:** If you still prefer using tags, you can filter notes by tags as well.

## Setting Up AI Note Suggestion

To use the AI Note Suggestion plugin, you'll need to set up [Weaviate](https://weaviate.io/), an AI vector search engine. We recommend using [Docker Compose](https://docs.docker.com/compose/) for an easier setup. You can also use weaviate cloud service if you don't want to use your local machine as a server. Here are the steps to get started:

**Step 1: Install Docker**
If you don't have [Docker](https://docs.docker.com/) installed on your machine, you'll need to do so. Docker provides a platform for running [Weaviate](https://weaviate.io/)

**Step 2: Download Weaviate Using Docker Compose**
You can check out [weaviate's install guides](https://weaviate.io/developers/weaviate/installation) for in depth information or if you are new to this follow instruction bellow,

1. Create a `docker-compose.yml` file with the following content:

```yaml
weaviate-obsidian:
container_name: weaviate-obsidian
depends_on:
- t2v-transformers-obsidian
command:
- --host
- 0.0.0.0
- --port
- '8080'
- --scheme
- http
image: semitechnologies/weaviate
ports:
- 3636:8080
volumes:
- ./data/weaviate-data:/var/lib/weaviate
restart: unless-stopped
environment:
TRANSFORMERS_INFERENCE_API: 'http://t2v-transformers-obsidian:8080'
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
DEFAULT_VECTORIZER_MODULE: 'text2vec-transformers'
ENABLE_MODULES: 'text2vec-transformers'
CLUSTER_HOSTNAME: 'node1'


t2v-transformers-obsidian:
container_name: t2v-transformers-obsidian
image: semitechnologies/transformers-inference:sentence-transformers-multi-qa-MiniLM-L6-cos-v1
restart: unless-stopped
environment:
ENABLE_CUDA: '0'
```
2. In the directory where you saved the `docker-compose.yml` file, run the following command
```bash
docker-compose up -d
```
This command pulls the Weaviate image from Docker Hub and runs it as a container on your local machine.

**Step 3: Configure AI Note Suggestion**

1. Once you have Weaviate up and running, go to the settings of the **AI Note Suggestion** plugin in Obsidian.
2. In the plugin settings, provide the **Weaviate Address** where your Weaviate instance is running (usually `http://localhost:3636` if you followed the default settings)


Now, you're all set to enjoy the enhanced note-taking experience provided by the AI Note Suggestion plugin!

## Code blocks for query
This is a simple code blocks for querying similar notes based on given texts


~~~markdown
```match
text: one
showPercentage: true
limit: 10
distanceLimit: .98
autoCut: 2
```
~~~



## Todo's
- [x] Side pane list
- [x] add yaml for code query for tags
- [x] Code query inside files like
- [x] remove code blocks when update files on weaviate
- [x] extract tags and update file with tags
- [x] Similar notes inside note
- [x] add autocut settings and yaml code
- [x] add distance threshold on settings and yaml code
- [ ] Split notes by regex and upload splits note in vector for long notes
- [ ] add a search command to search by similar text
- [ ] show status on every events (update,sync etc)

127 changes: 127 additions & 0 deletions SettingTab.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import { App, Notice, PluginSettingTab, Setting } from 'obsidian';
import MyPlugin from 'main';

export class MatchUpSettingTab extends PluginSettingTab {
plugin: MyPlugin;

constructor(app: App, plugin: MyPlugin) {
super(app, plugin);
this.plugin = plugin;
}

display(): void {
const {containerEl} = this;

containerEl.empty();

new Setting(containerEl)
.setName('Weaviate Address')
.setDesc('Enter your weaviate address ex: localhost:3636')
.addText(text => text
.setPlaceholder('ex: localhost:6636')
.setValue(this.plugin.settings.weaviateAddress)
.onChange(async (value) => {
this.plugin.settings.weaviateAddress = value;
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Class')
.setDesc('Weaviate class name')
.addText(text => text
.setPlaceholder('ex: Obsidian')
.setValue(this.plugin.settings.weaviateClass)
.onChange(async (value) => {
this.plugin.settings.weaviateClass = value;
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Suggestion Limit')
.setDesc('Limit for how much result you want to see (max 30)')
.addText(t => t
.setPlaceholder("ex: 30")
.setValue(`${this.plugin.settings.limit}`)
.onChange(async (value) => {
if(parseInt(value)>30){
t.setValue("30")
}else if (parseInt(value)<=0){
t.setValue("1")
}
this.plugin.settings.limit = parseInt(value);
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Similarity Distance')
.setDesc('Modify this if you want to set a similarity threshold, 2 is the lowest value (0 to disable). for more information check here \
https://weaviate.io/developers/weaviate/search/similarity#distance-threshold')
.addText(t => t
.setPlaceholder("ex: 70 ")
.setValue(`${this.plugin.settings.distanceLimit}`)
.onChange(async (value) => {
let newval = value
if(parseFloat(value)>2){
t.setValue("2")
newval=2
}else if (parseFloat(value)<0){
t.setValue("0")
newval=0
}
this.plugin.settings.distanceLimit = parseFloat(newval);
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Enable Autocut')
.setDesc('Leave it 0 to disable if you don\'t know what is it. For info check here https://weaviate.io/developers/weaviate/search/similarity#autocut ')
.addText(t => t
.setPlaceholder("ex: 1 ")
.setValue(`${this.plugin.settings.autoCut}`)
.onChange(async (value) => {
if (parseInt(value)<0){
t.setValue("0")
}
this.plugin.settings.autoCut = parseInt(value);
await this.plugin.saveSettings();
}));

new Setting(containerEl)
.setName('Show Percentage on query')
.setDesc('Enable this if you want to get the match percentage info in code query')
.addToggle(
t=>t
.setValue(this.plugin.settings.showPercentageOnCodeQuery)
.onChange(async v=>{
this.plugin.settings.showPercentageOnCodeQuery = v;
await this.plugin.saveSettings();
}))



new Setting(containerEl)
.setName('Show similar notes on top')
.setDesc('If you enable this , plugin will show related notes on top of the current note')
.addToggle(
t=>t
.setValue(this.plugin.settings.inDocMatchNotes)
.onChange(async v=>{
this.plugin.settings.inDocMatchNotes = v;
await this.plugin.saveSettings();
}))



new Setting(containerEl)
.setName('Re-build')
.setDesc('Remove everything from weaviate and rebuild')
.addButton(btn=> btn
.setButtonText("Delete all")
.onClick(()=>{
new Notice("Removing everything from weaviate")
this.plugin.vectorHelper.deleteAll()
})
)

}
}
Loading

0 comments on commit 0ec8b72

Please sign in to comment.