Skip to content

Commit

Permalink
Eliminated unneeded fail flag check from OpenAI text processing
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Jan 26, 2025
1 parent f73c6d9 commit f26584c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 47 deletions.
16 changes: 5 additions & 11 deletions amazongpt/greasemonkey/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.9
// @version 2025.1.26.10
// @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 @@ -2727,16 +2727,10 @@
: ['openAInotWorking', 'suggestProxy'] )
else api.tryNew(caller)
} else if (callerAPI == 'OpenAI' && resp.response) { // show response from OpenAI
const failMatch = reFailFlags?.exec(resp.response)
if (failMatch) { // suggest proxy
log.debug('Response text', resp.response) ; log.error('Fail flag detected', `'${failMatch[0]}'`)
appAlert('openAInotWorking', 'suggestProxy')
} else {
try { // to show response
textToShow = JSON.parse(resp.response).choices[0].message.content
handleProcessCompletion()
} catch (err) { handleProcessError(err) }
}
try { // to show response
textToShow = JSON.parse(resp.response).choices[0].message.content
handleProcessCompletion()
} catch (err) { handleProcessError(err) }
} else if (resp.responseText) { // show response from proxy API
if (!apis[callerAPI].parsingRequired) { textToShow = resp.responseText ; handleProcessCompletion() }
else { // parse structured responseText
Expand Down
17 changes: 5 additions & 12 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.26.9
// @version 2025.1.26.10
// @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 @@ -3477,17 +3477,10 @@
: ['openAInotWorking', 'suggestProxy'] )
else api.tryNew(caller)
} else if (callerAPI == 'OpenAI' && resp.response) { // show response or return RQs from OpenAI
const failMatch = reFailFlags?.exec(resp.response)
if (failMatch) { // suggest proxy or try diff API
log.debug('Response text', resp.response) ; log.error('Fail flag detected', `'${failMatch[0]}'`)
if (caller == get.reply) appAlert('openAInotWorking', 'suggestProxy')
else api.tryNew(caller)
} else {
try { // to show response or return RQs
textToShow = JSON.parse(resp.response).choices[0].message.content
handleProcessCompletion()
} catch (err) { handleProcessError(err) }
}
try { // to show response or return RQs
textToShow = JSON.parse(resp.response).choices[0].message.content
handleProcessCompletion()
} catch (err) { handleProcessError(err) }
} else if (resp.responseText) { // show response or return RQs from proxy API
if (!apis[callerAPI].parsingRequired) { textToShow = resp.responseText ; handleProcessCompletion() }
else { // parse structured responseText
Expand Down
17 changes: 5 additions & 12 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.26.9
// @version 2025.1.26.10
// @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 @@ -3361,17 +3361,10 @@
: ['openAInotWorking', 'suggestProxy'] )
else api.tryNew(caller)
} else if (callerAPI == 'OpenAI' && resp.response) { // show response or return RQs from OpenAI
const failMatch = reFailFlags?.exec(resp.response)
if (failMatch) { // suggest proxy or try diff API
log.debug('Response text', resp.response) ; log.error('Fail flag detected', `'${failMatch[0]}'`)
if (caller == get.reply) appAlert('openAInotWorking', 'suggestProxy')
else api.tryNew(caller)
} else {
try { // to show response or return RQs
textToShow = JSON.parse(resp.response).choices[0].message.content
handleProcessCompletion()
} catch (err) { handleProcessError(err) }
}
try { // to show response or return RQs
textToShow = JSON.parse(resp.response).choices[0].message.content
handleProcessCompletion()
} catch (err) { handleProcessError(err) }
} else if (resp.responseText) { // show response or return RQs from proxy API
if (!apis[callerAPI].parsingRequired) { textToShow = resp.responseText ; handleProcessCompletion() }
else { // parse structured responseText
Expand Down
17 changes: 5 additions & 12 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.26.9
// @version 2025.1.26.10
// @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 @@ -3658,17 +3658,10 @@
: ['openAInotWorking', 'suggestProxy'] )
else api.tryNew(caller)
} else if (callerAPI == 'OpenAI' && resp.response) { // show response or return RQs from OpenAI
const failMatch = reFailFlags?.exec(resp.response)
if (failMatch) { // suggest proxy or try diff API
log.debug('Response text', resp.response) ; log.error('Fail flag detected', `'${failMatch[0]}'`)
if (caller == get.reply) appAlert('openAInotWorking', 'suggestProxy')
else api.tryNew(caller)
} else {
try { // to show response or return RQs
textToShow = JSON.parse(resp.response).choices[0].message.content
handleProcessCompletion()
} catch (err) { handleProcessError(err) }
}
try { // to show response or return RQs
textToShow = JSON.parse(resp.response).choices[0].message.content
handleProcessCompletion()
} catch (err) { handleProcessError(err) }
} else if (resp.responseText) { // show response or return RQs from proxy API
if (!apis[callerAPI].parsingRequired) { textToShow = resp.responseText ; handleProcessCompletion() }
else { // parse structured responseText
Expand Down

0 comments on commit f26584c

Please sign in to comment.