Skip to content

Commit

Permalink
AI infered tags can contain " " at the beginning hoarder-app#184
Browse files Browse the repository at this point in the history
added a trim to tags to prevent whitespaces at the beginning/end of tags
  • Loading branch information
kamtschatka committed Jun 4, 2024
1 parent 9d89f98 commit 08ba133
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/workers/openaiWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 08ba133

Please sign in to comment.