aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workers
diff options
context:
space:
mode:
authorkamtschatka <sschatka@gmail.com>2024-06-07 11:24:16 +0200
committerGitHub <noreply@github.com>2024-06-07 10:24:16 +0100
commitbe8b91f97cc004119bab27b7f145cc77e3d257bb (patch)
treed910076ca5b76ab10fc258aaedfcf7ba6e0ffedf /apps/workers
parent9d89f987ba0748bbf978d17b815040d316b19620 (diff)
downloadkarakeep-be8b91f97cc004119bab27b7f145cc77e3d257bb.tar.zst
fix(workers): AI infered tags can contain " " at the beginning. Fixes #184 (#194)
added a trim to tags to prevent whitespaces at the beginning/end of tags Co-authored-by: kamtschatka <simon.schatka@gmx.at>
Diffstat (limited to 'apps/workers')
-rw-r--r--apps/workers/openaiWorker.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/workers/openaiWorker.ts b/apps/workers/openaiWorker.ts
index 697c9c53..7b74e4c3 100644
--- a/apps/workers/openaiWorker.ts
+++ b/apps/workers/openaiWorker.ts
@@ -257,11 +257,13 @@ async function inferTags(
);
// Sometimes the tags contain the hashtag symbol, let's strip them out if they do.
+ // Additionally, trim the tags to prevent whitespaces at the beginning/the end of the tag.
tags = tags.map((t) => {
- if (t.startsWith("#")) {
- return t.slice(1);
+ let tag = t;
+ if (tag.startsWith("#")) {
+ tag = t.slice(1);
}
- return t;
+ return tag.trim();
});
return tags;