fix(chat): always show model badge for image replies
This commit is contained in:
parent
45fa541b2d
commit
d68512b71a
@ -174,6 +174,19 @@ function filterAgentRoutingNoise(text: string): string {
|
||||
}
|
||||
|
||||
const IMAGE_DONE_SUMMARY = "已完成本次生成,如需微调可继续告诉我。";
|
||||
const MODEL_BADGE_REGEX =
|
||||
/^\s*[◈◇◆🔹⬡✦•·]\s*[A-Za-z][A-Za-z0-9 .:+\-_/()]{2,}\s*$/im;
|
||||
|
||||
function ensureImageModelBadge(text: string, fallbackModelName?: string): string {
|
||||
if (!text) return text;
|
||||
const normalized = String(text || "").trim();
|
||||
if (!normalized) return normalized;
|
||||
const modelName = String(fallbackModelName || "").trim();
|
||||
if (!modelName) return normalized;
|
||||
if (!/!\[[^\]]*\]\((https?:\/\/[^\s)]+)\)/i.test(normalized)) return normalized;
|
||||
if (MODEL_BADGE_REGEX.test(normalized)) return normalized;
|
||||
return `◈ ${modelName}\n\n${normalized}`;
|
||||
}
|
||||
|
||||
function appendImageDoneSummary(text: string): string {
|
||||
if (!text) return text;
|
||||
@ -208,6 +221,7 @@ const PurePreviewMessage = ({
|
||||
isProcessingExtend,
|
||||
isProcessingAngleEdit,
|
||||
isProcessingWatermarkRemove,
|
||||
fallbackImageModelName,
|
||||
}: {
|
||||
chatId: string;
|
||||
message: ChatMessage;
|
||||
@ -230,6 +244,7 @@ const PurePreviewMessage = ({
|
||||
isProcessingExtend?: boolean;
|
||||
isProcessingAngleEdit?: boolean;
|
||||
isProcessingWatermarkRemove?: boolean;
|
||||
fallbackImageModelName?: string;
|
||||
}) => {
|
||||
const [mode, setMode] = useState<"view" | "edit">("view");
|
||||
|
||||
@ -329,7 +344,12 @@ const PurePreviewMessage = ({
|
||||
// 应用视频内容过滤
|
||||
const filteredText =
|
||||
message.role === "assistant"
|
||||
? appendImageDoneSummary(filterAgentRoutingNoise(filterVideoContent(part.text)))
|
||||
? appendImageDoneSummary(
|
||||
ensureImageModelBadge(
|
||||
filterAgentRoutingNoise(filterVideoContent(part.text)),
|
||||
fallbackImageModelName
|
||||
)
|
||||
)
|
||||
: part.text;
|
||||
const textParts = parseAnnotations(filteredText);
|
||||
|
||||
|
||||
@ -550,6 +550,7 @@ function PureMessages({
|
||||
isProcessingExtend={isProcessingExtend}
|
||||
isProcessingAngleEdit={isProcessingAngleEdit}
|
||||
isProcessingWatermarkRemove={isProcessingWatermarkRemove}
|
||||
fallbackImageModelName={currentModelDisplayName}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user