Skip to content

Commit

Permalink
Simplified xhrConfig.url init in get.related() for readability ↞ …
Browse files Browse the repository at this point in the history
  • Loading branch information
kudo-sync-bot committed Jan 15, 2025
1 parent 34843f3 commit fbbac95
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions chatgpt/bravegpt/bravegpt.user.js
Original file line number Diff line number Diff line change
@@ -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.15.3
// @version 2025.1.15.4
// @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
@@ -3370,18 +3370,18 @@
) api.tryNew(get.related, 'timeout')
}, 7000)

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

0 comments on commit fbbac95

Please sign in to comment.