mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: JSON parse error
This commit is contained in:
parent
4330e61dc3
commit
133eb0e87d
1 changed files with 7 additions and 2 deletions
|
|
@ -70,10 +70,15 @@ export class OfficialChatGPTClient {
|
|||
if (Config.debug) {
|
||||
logger.mark(fullResponse)
|
||||
}
|
||||
fullResponse = JSON.parse(fullResponse)
|
||||
try {
|
||||
fullResponse = JSON.parse(fullResponse)
|
||||
} catch (e) {
|
||||
let detail = JSON.parse(bodyText)
|
||||
throw new Error(detail.detail || 'unkown error, please check log')
|
||||
}
|
||||
if (!fullResponse?.message) {
|
||||
let detail = JSON.parse(bodyText)
|
||||
throw new Error(detail.detail || 'unkown error')
|
||||
throw new Error(detail.detail || 'unkown error, please check log')
|
||||
}
|
||||
return {
|
||||
text: fullResponse.message.content.parts[0],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue