Skip to content

Commit

Permalink
Improved prompts.create()
Browse files Browse the repository at this point in the history
± Added `mods` option
+ Expanded symbols checked before appending missing punctuation
+ Added lowercase 1st char of mod if preceded by one w/ trailing comma ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/amazongpt]
  • Loading branch information
kudo-sync-bot committed Jan 20, 2025
1 parent cc815e6 commit 5527f67
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 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.19.5
// @version 2025.1.19.6
// @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 @@ -2189,13 +2189,23 @@

augment(prompt) { return `${prompt} {{reply in the language ${config.replyLang}}}` },

create({ type }) {
const promptSrc = this[type],
modsToApply = promptSrc.mods?.flatMap(mod => typeof mod == 'string' ? mod : mod.mods) || [],
promptElems = [promptSrc.base, ...modsToApply].map(elem => elem += /[\n.]$/.test(elem) ? '' : '.')
create({ type, mods }) {
mods = [].concat(mods || []) // normalize mods into array
const promptSrc = this[type]
const modsToApply = promptSrc.mods?.flatMap(mod =>
!mods.length && typeof mod == 'string' ? mod // string if no mods passed
: !mods.length || mods.includes(mod.type) ? mod.mods : [] // sub-array if no mods passed or includes type
) || []
const promptElems = [promptSrc.base || '', ...modsToApply].map((elem, idx, array) => {
if (elem && !/[\n,.!]$/.test(elem)) elem += '.' // append missing punctuation
if (idx > 0 && array[idx -1].endsWith(',')) // prev elem ended in comma...
elem = elem.charAt(0).toLowerCase() + elem.slice(1) // ...so lowercase 1st char of this one
return elem
})
return promptElems.join(' ').trim()
},


informCategory: {
get base() {
return `Tell me more about what to look for when shopping for this category: ${document.title}`
Expand Down

0 comments on commit 5527f67

Please sign in to comment.