Skip to content

Commit

Permalink
Merged done signal check for parsable APIs using new `respPatterns.do…
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Jan 26, 2025
1 parent 24419b8 commit e530ec6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions chatgpt/amazongpt/amazongpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @description Adds the magic of AI to Amazon shopping
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.26.3
// @version 2025.1.26.4
// @license MIT
// @icon https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon48.png?v=0fddfc7
// @icon64 https://amazongpt.kudoai.com/assets/images/icons/amazongpt/black-gold-teal/icon64.png?v=0fddfc7
Expand Down Expand Up @@ -2665,16 +2665,15 @@
else { // AI response
apis.GPTforLove.parentID = chunkObjs[0].id || null // for contextual replies
chunkObjs.forEach(obj => replyChunk += obj.delta || '') // accumulate AI reply text
if (respChunk.includes('"finish_reason":"stop"')) isDone = true
}
} else if (callerAPI == 'MixerBox AI') { // extract/normalize AI reply data
replyChunk = [...respChunk.matchAll(/data:(.*)/g)] // arrayify data
.filter(match => !/message_(?:start|end)|done/.test(match)) // exclude signals
.map(match => // normalize whitespace
match[1].replace(/\[SPACE\]/g, ' ').replace(/\[NEWLINE\]/g, '\n'))
.join('') // stringify AI reply text
if (/data:(?:message_end|done)/.test(respChunk)) isDone = true
} textToShow += replyChunk
if (new RegExp(apis[callerAPI].respPatterns?.done).test(respChunk)) isDone = true
}

// Show accumulated reply chunks
Expand Down

0 comments on commit e530ec6

Please sign in to comment.