fix(canvas): hide raw anchor/html text in video assistant messages
This commit is contained in:
parent
26dea0141c
commit
bdf980044a
@ -134,6 +134,16 @@ function extractVideoUrls(text: string): string[] {
|
|||||||
return Array.from(urls);
|
return Array.from(urls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stripMediaMarkup(text: string): string {
|
||||||
|
return String(text || "")
|
||||||
|
.replace(/!\[(?:thumb)?\|\|\|[^|]+\|\|\|[^\]]*\]\([^)]+\)/g, "")
|
||||||
|
.replace(/<video[\s\S]*?<\/video>/gi, "")
|
||||||
|
.replace(/<a[\s\S]*?<\/a>/gi, "")
|
||||||
|
.replace(/\[[^\]]*]\((https?:\/\/[^)\s]+\.mp4(?:\?[^)\s]*)?)\)/gi, "")
|
||||||
|
.replace(/https?:\/\/[^\s"'<>]+\.mp4(?:\?[^\s"'<>]+)?/gi, "")
|
||||||
|
.trim();
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeVideoParamsForProvider(
|
function normalizeVideoParamsForProvider(
|
||||||
params: VideoGenerationParams | null | undefined,
|
params: VideoGenerationParams | null | undefined,
|
||||||
providerType?: string
|
providerType?: string
|
||||||
@ -3277,13 +3287,7 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
|||||||
extractVideoUrls(part.text || "").length > 0
|
extractVideoUrls(part.text || "").length > 0
|
||||||
);
|
);
|
||||||
const hasAssistantText = assistantTextParts.some((part: any) => {
|
const hasAssistantText = assistantTextParts.some((part: any) => {
|
||||||
const textWithoutImages = (part.text || "")
|
return stripMediaMarkup(part.text).length > 0;
|
||||||
.replace(/!\[(?:thumb)?\|\|\|[^|]+\|\|\|[^\]]*\]\([^)]+\)/g, "")
|
|
||||||
.replace(/<video[\s\S]*?<\/video>/gi, "")
|
|
||||||
.replace(/\[[^\]]*]\((https?:\/\/[^)\s]+\.mp4(?:\?[^)\s]*)?)\)/gi, "")
|
|
||||||
.replace(/https?:\/\/[^\s"'<>]+\.mp4(?:\?[^\s"'<>]+)?/gi, "")
|
|
||||||
.trim();
|
|
||||||
return textWithoutImages.length > 0;
|
|
||||||
});
|
});
|
||||||
const isImageOnlyAssistant =
|
const isImageOnlyAssistant =
|
||||||
message.role === "assistant" &&
|
message.role === "assistant" &&
|
||||||
@ -3422,12 +3426,7 @@ export function CanvasChatPanel({ chatId, initialMessages = [], onClose, onOpenF
|
|||||||
const rawText = part.text || '';
|
const rawText = part.text || '';
|
||||||
const imageUrls = extractImageUrls(rawText);
|
const imageUrls = extractImageUrls(rawText);
|
||||||
const videoUrls = extractVideoUrls(rawText);
|
const videoUrls = extractVideoUrls(rawText);
|
||||||
const textWithoutImages = rawText
|
const textWithoutImages = stripMediaMarkup(rawText);
|
||||||
.replace(/!\[(?:thumb)?\|\|\|[^|]+\|\|\|[^\]]*\]\([^)]+\)/g, '')
|
|
||||||
.replace(/<video[\s\S]*?<\/video>/gi, '')
|
|
||||||
.replace(/\[[^\]]*]\((https?:\/\/[^)\s]+\.mp4(?:\?[^)\s]*)?)\)/gi, '')
|
|
||||||
.replace(/https?:\/\/[^\s"'<>]+\.mp4(?:\?[^\s"'<>]+)?/gi, '')
|
|
||||||
.trim();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={i}>
|
<div key={i}>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user