Spaces:
Sleeping
Sleeping
File size: 693 Bytes
32d42b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | """
Message normalization helpers for Notiflow.
"""
from __future__ import annotations
import re
class MessageParser:
"""Normalize incoming business messages before they reach the agents."""
_whitespace_pattern = re.compile(r"\s+")
def parse(self, message: str) -> str:
"""Normalize a message for downstream LLM processing."""
if message is None:
return ""
normalized = str(message).strip().lower()
normalized = self._whitespace_pattern.sub(" ", normalized)
return normalized
def parse_message(message: str) -> str:
"""Convenience wrapper used by the backend entry point."""
return MessageParser().parse(message)
|