fix: 优化错误提示
This commit is contained in:
1 parent
d57ecc62f9
commit
239d373503
14 files changed
+333
-38
No files matched your search
@@ -3,10 +3,11 @@
|
||||
* 用途:统一发起 Chat Turn(POST /api/chat/turns/stream),复用与 sendMessage 相同的 SSE 渲染链路。
|
||||
* 依赖:chat-turn.types、useChat 的 shipping UI 同步、streamErrorMessage、auth headers。
|
||||
* 逻辑:useChat 构造 startChatTurn 并导出;货代/请假等业务只构造 actionType + payload。
|
||||
* error / run.failed 若带 user_facing,则展示后端原文,同一轮只写一次。
|
||||
*/
|
||||
import { type Ref } from 'vue';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { applyStreamErrorToMessage, type StreamErrorLabels } from '../utils/streamErrorMessage';
|
||||
import { applyStreamErrorToMessage, isUserFacingStreamError, type StreamErrorLabels } from '../utils/streamErrorMessage';
|
||||
import type { StartChatTurnOptions } from '../types/chat-turn.types';
|
||||
import type { ChatMessage, ChatRun } from '../types/chat.types';
|
||||
import { applyShippingUiStateToMessage } from './useChat';
|
||||
@@ -210,8 +211,14 @@ export function createStartChatTurn(options: CreateStartChatTurnOptions) {
|
||||
hasTerminalEvent = true;
|
||||
run.status = 'error';
|
||||
const botMsg = ensureBotMessage();
|
||||
if (botMsg) {
|
||||
applyStreamErrorToMessage(botMsg, options.formatStreamError(data.message), options.streamErrorLabels());
|
||||
// run.failed 与兼容用的 error 帧会连发;已写入的失败提示不再追加第二遍。
|
||||
if (botMsg && !botMsg.stream_error) {
|
||||
applyStreamErrorToMessage(
|
||||
botMsg,
|
||||
options.formatStreamError(data.message),
|
||||
options.streamErrorLabels(),
|
||||
{ userFacing: isUserFacingStreamError(data) },
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user