Merge pull request #2264 from racinmat/staging
fix: correct usage of fuzzy search in emotion detection by LLM
This commit is contained in:
commit
4219468e20
|
@ -1020,12 +1020,12 @@ function parseLlmResponse(emotionResponse, labels) {
|
|||
const parsedEmotion = JSON.parse(emotionResponse);
|
||||
return parsedEmotion?.emotion ?? fallbackExpression;
|
||||
} catch {
|
||||
const fuse = new Fuse([emotionResponse]);
|
||||
for (const label of labels) {
|
||||
const result = fuse.search(label);
|
||||
if (result.length > 0) {
|
||||
return label;
|
||||
}
|
||||
const fuse = new Fuse(labels, {includeScore: true});
|
||||
console.debug("Using fuzzy search in labels: " + labels.join(', '))
|
||||
const result = fuse.search(emotionResponse);
|
||||
if (result.length > 0) {
|
||||
console.debug("fuzzy search found: " + result[0].item + " as closest for the LLM response: " + emotionResponse)
|
||||
return result[0].item;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue