From be8b91f97cc004119bab27b7f145cc77e3d257bb Mon Sep 17 00:00:00 2001 From: kamtschatka Date: Fri, 7 Jun 2024 11:24:16 +0200 Subject: 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 --- apps/workers/openaiWorker.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'apps') 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; -- cgit v1.2.3-70-g09d2