feat: improve public chat UI and shared components

This commit is contained in:
CREDO23 2026-01-26 18:39:59 +02:00
parent 37adc54d6a
commit ee65e1377f
14 changed files with 403 additions and 275 deletions

View file

@ -23,9 +23,18 @@ UI_TOOLS = {
def strip_citations(text: str) -> str:
"""Remove [citation:X] and [citation:doc-X] patterns from text."""
text = re.sub(r"\[citation:(doc-)?\d+\]", "", text)
text = re.sub(r"\s+", " ", text)
"""
Remove [citation:X] and [citation:doc-X] patterns from text.
Preserves newlines to maintain markdown formatting.
"""
# Remove citation patterns (including Chinese brackets 【】)
text = re.sub(r"[\[【]citation:(doc-)?\d+[\]】]", "", text)
# Collapse multiple spaces/tabs (but NOT newlines) into single space
text = re.sub(r"[^\S\n]+", " ", text)
# Normalize excessive blank lines (3+ newlines → 2)
text = re.sub(r"\n{3,}", "\n\n", text)
# Clean up spaces around newlines
text = re.sub(r" *\n *", "\n", text)
return text.strip()