Skip to content

Commit

Permalink
feat: handle JSON.parse error (#220)
Browse files Browse the repository at this point in the history
Co-authored-by: Shigma <[email protected]>
  • Loading branch information
idranme and shigma authored Feb 3, 2024
1 parent a2fab9a commit 86d422f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,17 @@ export function apply(ctx: Context, config: Config) {
})

if (config.type === 'sd-webui') {
finalPrompt = (JSON.parse((res.data as StableDiffusionWebUI.Response).info)).prompt
return forceDataPrefix((res.data as StableDiffusionWebUI.Response).images[0])
const data = res.data as StableDiffusionWebUI.Response
if (data?.info?.prompt) {
finalPrompt = data.info.prompt
} else {
try {
finalPrompt = (JSON.parse(data.info)).prompt
} catch (err) {
logger.warn(err)
}
}
return forceDataPrefix(data.images[0])
}
if (config.type === 'stable-horde') {
const uuid = res.data.id
Expand Down

0 comments on commit 86d422f

Please sign in to comment.