MCPcopy Create free account
hub / github.com/HKUDS/OpenSpace / _split_text

Function _split_text

openspace/communication/adapters/feishu.py:794–812  ·  view source on GitHub ↗
(content: str, limit: int)

Source from the content-addressed store, hash-verified

792
793
794def _split_text(content: str, limit: int) -> list[str]:
795 text = content.strip()
796 if not text:
797 return [""]
798 if len(text) <= limit:
799 return [text]
800 chunks = []
801 remaining = text
802 while remaining:
803 chunk = remaining[:limit]
804 if len(remaining) > limit:
805 split_at = chunk.rfind("\n")
806 if split_at < limit // 3:
807 split_at = chunk.rfind(" ")
808 if split_at >= limit // 3:
809 chunk = chunk[:split_at]
810 chunks.append(chunk.strip())
811 remaining = remaining[len(chunk):].lstrip()
812 return [chunk for chunk in chunks if chunk]
813
814
815def _is_webhook_signature_valid(*, encrypt_key: str, headers: Any, body_bytes: bytes) -> bool:

Callers 1

send_textMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected