|
148 | 148 | // @description:zu Yengeza izimpendulo ze-AI ku-DuckDuckGo (inikwa amandla yi-GPT-4o!) |
149 | 149 | // @author KudoAI |
150 | 150 | // @namespace https://kudoai.com |
151 | | -// @version 2025.1.13.6 |
| 151 | +// @version 2025.1.14 |
152 | 152 | // @license MIT |
153 | 153 | // @icon https://assets.ddgpt.com/images/icons/duckduckgpt/icon48.png?v=06af076 |
154 | 154 | // @icon64 https://assets.ddgpt.com/images/icons/duckduckgpt/icon64.png?v=06af076 |
|
595 | 595 | 'GPTforLove': { |
596 | 596 | endpoint: 'https://api11.gptforlove.com/chat-process', |
597 | 597 | expectedOrigin: { |
598 | | - url: 'https://ai27.gptforlove.com', |
| 598 | + url: 'https://ai28.gptforlove.com', |
599 | 599 | headers: { |
600 | 600 | 'Accept': 'application/json, text/plain, */*', 'Priority': 'u=0', 'Sec-Fetch-Site': 'same-site' |
601 | 601 | } |
|
3296 | 3296 | chunk = extractedChunks.join('') |
3297 | 3297 | } |
3298 | 3298 | accumulatedChunks = apis[caller.api].accumulatesText ? chunk : accumulatedChunks + chunk |
3299 | | - if (/^(?:\{|event:)/.test(accumulatedChunks)) api.tryNew(caller) |
3300 | | - else { |
3301 | | - try { // to show stream text |
3302 | | - let textToShow = '' |
3303 | | - if (caller.api == 'GPTforLove') { // extract parentID + latest chunk text |
3304 | | - const jsonLines = accumulatedChunks.split('\n'), |
3305 | | - nowResult = JSON.parse(jsonLines[jsonLines.length - 1]) |
3306 | | - if (nowResult.id) apis.GPTforLove.parentID = nowResult.id // for contextual replies |
3307 | | - textToShow = nowResult.text |
3308 | | - } else textToShow = accumulatedChunks |
3309 | | - const failMatch = failFlagsAndURLs.exec(textToShow) |
3310 | | - if (failMatch) { |
3311 | | - log.debug('Response text', textToShow) |
3312 | | - log.error('Fail flag detected', `'${failMatch[0]}'`) |
3313 | | - if (caller.status != 'done' && !caller.sender) api.tryNew(caller) |
3314 | | - return |
3315 | | - } else if (caller.status != 'done') { // app waiting or sending |
3316 | | - if (!caller.sender) caller.sender = caller.api // app is waiting, become sender |
3317 | | - if (caller.sender == caller.api // app is sending from this caller.api |
3318 | | - && textToShow.trim() != '' // empty chunk not read |
3319 | | - ) show.reply(textToShow) |
3320 | | - } |
3321 | | - } catch (err) { log.error('Error showing stream', err.message) } |
3322 | | - return reader.read().then(({ done, value }) => { |
3323 | | - if (caller.sender == caller.api) // am designated sender, recurse |
3324 | | - processStreamText({ done, value }) |
3325 | | - }).catch(err => log.error('Error reading stream', err.message)) |
3326 | | - } |
| 3299 | + try { // to show stream text |
| 3300 | + let textToShow = '' |
| 3301 | + if (caller.api == 'GPTforLove') { // extract parentID + latest chunk text |
| 3302 | + const jsonLines = accumulatedChunks.split('\n'), |
| 3303 | + nowResult = JSON.parse(jsonLines[jsonLines.length -1]) |
| 3304 | + if (nowResult.id) apis.GPTforLove.parentID = nowResult.id // for contextual replies |
| 3305 | + textToShow = nowResult.text // for AI response |
| 3306 | + || JSON.stringify(nowResult) // for error response |
| 3307 | + } else textToShow = accumulatedChunks |
| 3308 | + const failMatch = failFlagsAndURLs.exec(textToShow) |
| 3309 | + if (failMatch) { |
| 3310 | + log.debug('Response text', textToShow) |
| 3311 | + log.error('Fail flag detected', `'${failMatch[0]}'`) |
| 3312 | + if (caller.status != 'done' && !caller.sender) api.tryNew(caller) |
| 3313 | + return |
| 3314 | + } else if (caller.status != 'done') { // app waiting or sending |
| 3315 | + if (!caller.sender) caller.sender = caller.api // app is waiting, become sender |
| 3316 | + if (caller.sender == caller.api // app is sending from this caller.api |
| 3317 | + && textToShow.trim() != '' // empty chunk not read |
| 3318 | + ) show.reply(textToShow) |
| 3319 | + } |
| 3320 | + } catch (err) { log.error('Error showing stream', err.message) } |
| 3321 | + return reader.read().then(({ done, value }) => { |
| 3322 | + if (caller.sender == caller.api) // am designated sender, recurse |
| 3323 | + processStreamText({ done, value }) |
| 3324 | + }).catch(err => log.error('Error reading stream', err.message)) |
3327 | 3325 | } |
3328 | 3326 | }, |
3329 | 3327 |
|
|
0 commit comments