Skip to content

Commit

Permalink
Moved payload init outside Promise executor in get.related() to avo…
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Jan 14, 2025
1 parent 34f70a3 commit f5b88f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions bravegpt/greasemonkey/bravegpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-Brave Search (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.13
// @version 2025.1.13.1
// @license MIT
// @icon https://assets.bravegpt.com/images/icons/bravegpt/icon48.png?v=df624b0
// @icon64 https://assets.bravegpt.com/images/icons/bravegpt/icon64.png?v=df624b0
Expand Down Expand Up @@ -3388,11 +3388,12 @@
}, 7000)

// Get queries
return new Promise(async resolve => xhr({
const payload = await api.createPayload(get.related.api, [{ role: 'user', content: rqPrompt }])
return new Promise(resolve => xhr({
method: apis[get.related.api].method,
url: apis[get.related.api].endpoints?.completions || apis[get.related.api].endpoint,
responseType: 'text', headers: api.createHeaders(get.related.api),
data: await api.createPayload(get.related.api, [{ role: 'user', content: rqPrompt }]),
data: payload,
onload: resp => dataProcess.text(get.related, resp).then(resolve),
onerror: err => { log.error(err) ; api.tryNew(get.related) }
}))
Expand Down
7 changes: 4 additions & 3 deletions duckduckgpt/greasemonkey/duckduckgpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.13
// @version 2025.1.13.1
// @license MIT
// @icon https://assets.ddgpt.com/images/icons/duckduckgpt/icon48.png?v=06af076
// @icon64 https://assets.ddgpt.com/images/icons/duckduckgpt/icon64.png?v=06af076
Expand Down Expand Up @@ -3272,11 +3272,12 @@
}, 7000)

// Get queries
return new Promise(async resolve => xhr({
const payload = await api.createPayload(get.related.api, [{ role: 'user', content: rqPrompt }])
return new Promise(resolve => xhr({
method: apis[get.related.api].method,
url: apis[get.related.api].endpoints?.completions || apis[get.related.api].endpoint,
responseType: 'text', headers: api.createHeaders(get.related.api),
data: await api.createPayload(get.related.api, [{ role: 'user', content: rqPrompt }]),
data: payload,
onload: resp => dataProcess.text(get.related, resp).then(resolve),
onerror: err => { log.error(err) ; api.tryNew(get.related) }
}))
Expand Down
7 changes: 4 additions & 3 deletions googlegpt/greasemonkey/googlegpt.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
// @description:zu Yengeza izimpendulo ze-AI ku-Google Search (inikwa amandla yi-Google Gemma + GPT-4o!)
// @author KudoAI
// @namespace https://kudoai.com
// @version 2025.1.13
// @version 2025.1.13.1
// @license MIT
// @icon https://assets.googlegpt.io/images/icons/googlegpt/black/icon48.png?v=59409b2
// @icon64 https://assets.googlegpt.io/images/icons/googlegpt/black/icon64.png?v=59409b2
Expand Down Expand Up @@ -3609,11 +3609,12 @@
}, 7000)

// Get queries
return new Promise(async resolve => xhr({
const payload = await api.createPayload(get.related.api, [{ role: 'user', content: rqPrompt }])
return new Promise(resolve => xhr({
method: apis[get.related.api].method,
url: apis[get.related.api].endpoints?.completions || apis[get.related.api].endpoint,
responseType: 'text', headers: api.createHeaders(get.related.api),
data: await api.createPayload(get.related.api, [{ role: 'user', content: rqPrompt }]),
data: payload,
onload: resp => dataProcess.text(get.related, resp).then(resolve),
onerror: err => { log.error(err) ; api.tryNew(get.related) }
}))
Expand Down

0 comments on commit f5b88f0

Please sign in to comment.