Spaces:
Sleeping
Sleeping
Download app/utils/message_parser.py from dipan004/VyaparFlow: direct link, hf CLI and curl.
- Browser
- Download file 693 Bytes
-
https://huggingface.co/spaces/dipan004/VyaparFlow/resolve/main/app/utils/message_parser.py
- Command line
-
hf download hf://spaces/dipan004/VyaparFlow/app/utils/message_parser.py
-
curl -L -o message_parser.py https://huggingface.co/spaces/dipan004/VyaparFlow/resolve/main/app/utils/message_parser.py
693 Bytes
| """ | |
| 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) | |