Generic stateless helpers for tool functions.
No protocol or infrastructure imports. Pure utility functions.
sanitize_url(url: str) -> str
Ensure a URL has a scheme prefix.
Source code in src/symfonic/core/tools/helpers.py
| def sanitize_url(url: str) -> str:
"""Ensure a URL has a scheme prefix."""
url = url.strip()
if not url.startswith(("http://", "https://")):
url = "https://" + url
return url
|
truncate_text
truncate_text(text: str, max_length: int = 1000) -> str
Truncate text to max_length, appending '...' if shortened.
Source code in src/symfonic/core/tools/helpers.py
| def truncate_text(text: str, max_length: int = 1000) -> str:
"""Truncate text to max_length, appending '...' if shortened."""
if len(text) <= max_length:
return text
return text[: max_length - 3] + "..."
|