- Added new Radix UI components including checkbox, label, popover, slider, switch, and tooltip to improve UI interactions. - Integrated react-syntax-highlighter for better code rendering in chat messages. - Updated package.json and pnpm-lock.yaml to include new dependencies and ensure compatibility. - Enhanced chat input to support web search toggling, improving user experience during message composition. - Implemented auto-saving of chat sessions and improved session management features. - Refactored chat message rendering to clean up metadata and improve display quality.
24 lines
718 B
TypeScript
24 lines
718 B
TypeScript
const METADATA_BLOCK_REGEX = /<metadata>[\s\S]*?<\/metadata>/gi;
|
|
const METADATA_TAIL_REGEX = /(metadados?|metadata|hidden metadata block|bloco oculto de metadados|json metadata)\s*:?\s*/gi;
|
|
|
|
export function removeMetadataNoise(text: string): string {
|
|
if (!text) {
|
|
return '';
|
|
}
|
|
|
|
let cleaned = text.replace(METADATA_BLOCK_REGEX, '').trim();
|
|
|
|
// Remove any trailing sections that start with common metadata prefixes
|
|
cleaned = cleaned.replace(
|
|
/(metadados?|metadata|hidden metadata block|bloco oculto de metadados|json metadata)\s*:?\s*[\s\S]*$/gi,
|
|
'',
|
|
);
|
|
|
|
// Remove standalone prefixes that might appear inline
|
|
cleaned = cleaned.replace(METADATA_TAIL_REGEX, '');
|
|
|
|
return cleaned.trim();
|
|
}
|
|
|
|
|