feat(short-drama-agent-front): 接入联合修订与图片费用审计
This commit is contained in:
1 parent
87427d9d43
commit
f6edc4eb70
52 files changed
+5060
-516
No files matched your search
@@ -1,5 +1,12 @@
|
||||
/** 用户可操作的图片授权及视频费用审计错误,保留原码用于业务判断。 */
|
||||
const messages: Record<string, string> = {
|
||||
IMAGE_ADDITIONAL_AUTHORIZATION_INVALID: '人工追加许可无效、已撤销、用尽,或原精确计划与预算已变化,请重新核对。',
|
||||
IMAGE_BILLING_AUDIT_CONFLICT: '原图片请求或批准版本冲突,请重新读取审计。',
|
||||
IMAGE_BILLING_AUDIT_IDENTITY_MISMATCH: '材料与原图片请求身份不匹配,或供应方编号已归属其它请求。',
|
||||
IMAGE_BILLING_AUDIT_STALE: '原请求或完整证据集合已变化,请重新核对并确认。',
|
||||
IMAGE_BILLING_AUDIT_REVIEW_CONFLICT: '另一项图片费用复核已先完成,请刷新后重新核对。',
|
||||
IMAGE_BILLING_AUDIT_RELEASE_REJECTED: '尚不具备费用核清条件,请核对原执行、真实账单及唯一关联。',
|
||||
IMAGE_BILLING_AUDIT_EVIDENCE_INVALID: '图片审计历史或摘要无法核实,费用继续阻断。',
|
||||
IMAGE_AUTHORIZATION_REQUIRED: '当前模型或范围没有有效图片授权,授权可能已到期或撤销。请核对项目生成设置。',
|
||||
IMAGE_AUTHORIZATION_EXPIRED: '到期时间已过,请重新填写未来时间。',
|
||||
IMAGE_AUTHORIZATION_BUDGET_EXCEEDED: '图片授权剩余预算不足整次预留,或请求次数已用尽。',
|
||||
@@ -35,10 +42,34 @@ const failureMessages: Record<string, string> = {
|
||||
* @returns 可操作说明或空值
|
||||
*/
|
||||
export function billingErrorText(code: string | undefined, details: unknown): string | undefined {
|
||||
const record = details && typeof details === 'object' ? (details as Record<string, unknown>) : {}
|
||||
const outer = details && typeof details === 'object' ? (details as Record<string, unknown>) : {}
|
||||
const nested = outer.details && typeof outer.details === 'object' ? (outer.details as Record<string, unknown>) : {}
|
||||
const record = { ...outer, ...nested }
|
||||
const actualCode = code ?? (typeof record.code === 'string' ? record.code : undefined)
|
||||
if (actualCode && messages[actualCode]) return messages[actualCode]
|
||||
if (actualCode?.startsWith('OPENAI_IMAGE_'))
|
||||
return failureMessages[String(record.failureType)] ?? '图片请求结果或费用尚未核实,请查看原请求,禁止自动重发。'
|
||||
if (actualCode?.startsWith('OPENAI_IMAGE_')) {
|
||||
const cause =
|
||||
record.causeCode === 'UND_ERR_CONNECT_TIMEOUT'
|
||||
? '底层连接超时'
|
||||
: record.causeCode === 'ECONNREFUSED'
|
||||
? '底层连接被拒绝'
|
||||
: record.causeCode === 'ETIMEDOUT'
|
||||
? '底层请求超时'
|
||||
: ''
|
||||
const transport =
|
||||
record.transportMode === 'proxy'
|
||||
? '应用通过代理连接'
|
||||
: record.transportMode === 'direct'
|
||||
? '应用直接连接'
|
||||
: ''
|
||||
return [
|
||||
failureMessages[String(record.failureType)] ?? '图片请求结果或费用尚未核实,请查看原请求,禁止自动重发。',
|
||||
...(['network_error', 'timeout_unknown', 'receipt_unknown'].includes(String(record.failureType))
|
||||
? [transport, cause]
|
||||
: [])
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(';')
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
Reference in new issue
Block a user