(req, res)
| 1477 | } |
| 1478 | } |
| 1479 | |
| 1480 | if (newChatType === 't2i' || newChatType === 'image_edit') { |
| 1481 | const contentUrl = await resolveImageResultContentUrl(responseData.data, chatID, token) |
| 1482 | noteChatChallengeAnswer(breakerContext) |
| 1483 | return { |
| 1484 | model, |
| 1485 | chatType: newChatType, |
| 1486 | contentUrl, |
| 1487 | content: buildImageContent(contentUrl) |
| 1488 | } |
| 1489 | } |
| 1490 | |
| 1491 | if (newChatType === 't2v') { |
| 1492 | const contentUrl = await resolveVideoResultContentUrl(responseData.data, token, chatID) |
| 1493 | noteChatChallengeAnswer(breakerContext) |
| 1494 | return { |
| 1495 | model, |
| 1496 | chatType: newChatType, |
| 1497 | contentUrl, |
| 1498 | content: buildVideoContent(contentUrl) |
| 1499 | } |
| 1500 | } |
| 1501 | |
| 1502 | throw new Error('不支持的图片/视频类型') |
| 1503 | } catch (error) { |
| 1504 | logger.error('图片/视频主流程异常', 'CHAT', '', buildAxiosErrorLog(error)) |
| 1505 | |
| 1506 | if (error?.error) { |
| 1507 | if (!isWafChallengeError(error)) releaseChatProbe(breakerContext) |
| 1508 | throw error |
| 1509 | } |
| 1510 | |
| 1511 | const upstreamError = parseUpstreamBody(error.response?.data, breakerContext) |
| 1512 | if (upstreamError) { |
| 1513 | if (!isWafChallengeError(upstreamError)) releaseChatProbe(breakerContext) |
| 1514 | throw upstreamError |
| 1515 | } |
| 1516 | |
| 1517 | releaseChatProbe(breakerContext) |
| 1518 | throw { |
| 1519 | status: 500, |
no test coverage detected