feat: enhance input field and agent stream display with improved handling and sanitization
- Added blur handling for the textarea in the Input-field component to prevent errors when navigating away from the component. - Improved the sanitization process in the AgentStreamDisplay component to preserve specific tags during markdown processing, ensuring accurate content display. - Introduced new methods for handling FAQ-specific post-processing in the knowledge base service, optimizing retrieval and filtering of search results. These changes enhance user experience by improving input handling and content rendering in the chat interface.
This commit is contained in:
@@ -1352,7 +1352,21 @@ const getTokens = (content: any) => {
|
||||
const contentStr = typeof content === 'string' ? content : String(content || '');
|
||||
if (!contentStr.trim()) return [];
|
||||
|
||||
const processed = preprocessMarkdown(sanitizeForDisplay(contentStr));
|
||||
// Extract <kb.../> and <web.../> tags before sanitization to prevent
|
||||
// sanitizeForDisplay from stripping chunk_id labels and UUIDs inside them.
|
||||
const tagPlaceholders: string[] = [];
|
||||
const preserved = contentStr.replace(/<(?:kb|web)\b[^>]*\/>/g, (match) => {
|
||||
const idx = tagPlaceholders.length;
|
||||
tagPlaceholders.push(match);
|
||||
return `\x00TAG${idx}\x00`;
|
||||
});
|
||||
|
||||
let sanitized = sanitizeForDisplay(preserved);
|
||||
|
||||
// Restore preserved tags
|
||||
sanitized = sanitized.replace(/\x00TAG(\d+)\x00/g, (_, idx) => tagPlaceholders[Number(idx)]);
|
||||
|
||||
const processed = preprocessMarkdown(sanitized);
|
||||
return marked.lexer(processed);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user