Skip to content

Commit

Permalink
better check for complete embeddings before attempting similarity cal…
Browse files Browse the repository at this point in the history
…culation re: #13
  • Loading branch information
brianpetro committed Jan 11, 2023
1 parent 8ca67fb commit 78b996f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,14 +802,22 @@ class SmartConnectionsPlugin extends Obsidian.Plugin {
return "excluded";
}
}
// get from cache if mtime is same
// get from cache if mtime is same and values are not empty
let current_note_embedding_values = [];
if((this.embeddings[current_note.path]) && (this.embeddings[current_note.path].mtime >= current_note.stat.mtime)) {
// log skipping file
if (!this.embeddings[current_note.path]
|| !(this.embeddings[current_note.path].mtime >= current_note.stat.mtime)
|| !this.embeddings[current_note.path].values
|| !Array.isArray(this.embeddings[current_note.path].values)
|| !(this.embeddings[current_note.path].values.length > 0)
) {
// console.log("getting current")
await this.get_file_embeddings(current_note);
}else{
// skipping get file embeddings because nothing has changed
//console.log("skipping file (mtime)");
}else{
// console.log("getting current")
await this.get_file_embeddings(current_note);
}
if(!this.embeddings[current_note.path] || !this.embeddings[current_note.path].values) {
return "Error getting embeddings for: "+current_note.path;
}
current_note_embedding_values = this.embeddings[current_note.path].values;

Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Smart Connections",
"author": "Brian Petro",
"description": "Find links to similar notes using artificial intelligence from OpenAI.",
"version": "1.0.35",
"version": "1.0.36",
"minAppVersion": "1.1.0",
"authorUrl": "https://wfhbrian.com",
"isDesktopOnly": true
Expand Down

0 comments on commit 78b996f

Please sign in to comment.