fix(ai): 失败态给出可读文案,不再 stringify 整包兜底
后端判定工作流失败后不再下发 outputs / raw,前端需据此给出可读提示, 而不是把整包对象 JSON.stringify 进气泡(含 workflow_id / req_id 等内部标识符)。 - assistant/index.vue:新增 getPayloadStatus / isFailedPayload / buildFallbackText; formatCreativeResult 与 formatOutlineResult 失败态短路为固定文案; formatManuscriptResult、formatOutlineResult、formatCreativeResult 的整包 stringifyUnknown 兜底一律改为可读兜底文案 - 失败文案不取自 payload.answer:失败报文里它是 workflow_run_id(UUID), 原样展示等于把内部标识符贴给用户 - creative-assistant/index.vue:新增 workflowFailed,状态标签显示「执行失败」, 结果区给出失败文案,不再停在误导性的「待执行」空态 Refs: .scratch/ai-assistant/issues/01-creative-assistant-raw-json-bubble.md
This commit is contained in:
@@ -63,8 +63,8 @@
|
||||
<view class="panel-card result-card">
|
||||
<view class="result-head">
|
||||
<view class="panel-title">工作流结果</view>
|
||||
<view class="result-status" :class="loading ? 'result-status--loading' : hasAnyResult ? 'result-status--done' : ''">
|
||||
{{ loading ? '执行中' : hasAnyResult ? '已完成' : '待执行' }}
|
||||
<view class="result-status" :class="loading ? 'result-status--loading' : workflowFailed ? 'result-status--failed' : hasAnyResult ? 'result-status--done' : ''">
|
||||
{{ loading ? '执行中' : workflowFailed ? '执行失败' : hasAnyResult ? '已完成' : '待执行' }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -88,6 +88,10 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="workflowFailed" class="result-empty">
|
||||
{{ (workflowResponse && workflowResponse.answer) || '工作流执行失败,请稍后重试' }}
|
||||
</view>
|
||||
|
||||
<view v-else-if="!hasAnyResult" class="result-empty">
|
||||
填写文本指令并上传附件后执行工作流
|
||||
</view>
|
||||
@@ -248,6 +252,15 @@
|
||||
this.photoFiles.length
|
||||
)
|
||||
},
|
||||
/**
|
||||
* 后端判定工作流失败时不再下发 outputs/raw,只给 status + 可读 answer。
|
||||
* 这里据此提示失败,避免落到「待执行」空态误导用户(见 issue 01)。
|
||||
*/
|
||||
workflowFailed() {
|
||||
return String((this.workflowResponse && this.workflowResponse.status) || '')
|
||||
.trim()
|
||||
.toLowerCase() === 'failed'
|
||||
},
|
||||
loadingTitle() {
|
||||
if (this.uploadedFiles.length && String(this.content || '').trim()) {
|
||||
return '正在分析指令并处理附件'
|
||||
@@ -443,7 +456,11 @@
|
||||
const result = await creativeAssistant(this.buildRequestPayload())
|
||||
this.workflowResponse = result || null
|
||||
this.workflowOutputs = this.normalizeOutputPayload(result || null)
|
||||
if (!this.hasAnyResult) {
|
||||
if (this.workflowFailed) {
|
||||
this.showToast(
|
||||
(result && result.answer) || '工作流执行失败,请稍后重试'
|
||||
)
|
||||
} else if (!this.hasAnyResult) {
|
||||
this.showToast('接口已返回,但未识别到文档约定的输出字段')
|
||||
} else {
|
||||
this.showToast('工作流执行完成')
|
||||
@@ -787,6 +804,11 @@
|
||||
color: #1f8f49;
|
||||
}
|
||||
|
||||
.result-status--failed {
|
||||
background: #fdeeee;
|
||||
color: #c0392b;
|
||||
}
|
||||
|
||||
.result-empty {
|
||||
margin-top: 22rpx;
|
||||
padding: 32rpx 24rpx;
|
||||
|
||||
Reference in New Issue
Block a user