Skip to content

Commit

Permalink
decrease MAX_EMBED_STRING_LENGTH re: #10
Browse files Browse the repository at this point in the history
  • Loading branch information
brianpetro committed Jan 10, 2023
1 parent bb8ca02 commit 4579a54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const DEFAULT_SETTINGS = {
show_full_path: false,
log_render: false,
};
const MAX_EMBED_STRING_LENGTH = 25000;

class SmartConnectionsPlugin extends Obsidian.Plugin {
// constructor
Expand Down Expand Up @@ -442,7 +443,7 @@ class SmartConnectionsPlugin extends Obsidian.Plugin {
// for each heading in file
if(typeof note_meta_cache.headings === "undefined") {
// console.log("no headings found, using first chunk of file instead");
embed_input += note_contents.substring(0, 30000);
embed_input += note_contents.substring(0, MAX_EMBED_STRING_LENGTH);
// console.log("chuck len: " + embed_input.length);
}else{
let note_headings = "";
Expand All @@ -461,8 +462,8 @@ class SmartConnectionsPlugin extends Obsidian.Plugin {
}
//console.log(note_headings);
embed_input += note_headings
if(embed_input.length > 30000) {
embed_input = embed_input.substring(0, 30000);
if(embed_input.length > MAX_EMBED_STRING_LENGTH) {
embed_input = embed_input.substring(0, MAX_EMBED_STRING_LENGTH);
}
}
}
Expand Down Expand Up @@ -795,8 +796,8 @@ class SmartConnectionsPlugin extends Obsidian.Plugin {
return sections;

function output_section() {
if (section.length > 30000) {
section = section.substring(0, 30000);
if (section.length > MAX_EMBED_STRING_LENGTH) {
section = section.substring(0, MAX_EMBED_STRING_LENGTH);
}
sections.push({ text: section.trim(), path: section_path });
}
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.29",
"version": "1.0.30",
"minAppVersion": "1.1.0",
"authorUrl": "https://wfhbrian.com",
"isDesktopOnly": true
Expand Down

0 comments on commit 4579a54

Please sign in to comment.