diff --git a/src/copaw/app/channels/base.py b/src/copaw/app/channels/base.py index c4e466bc4..e46264687 100644 --- a/src/copaw/app/channels/base.py +++ b/src/copaw/app/channels/base.py @@ -344,7 +344,7 @@ def build_agent_request_from_user_content( if not content_parts: content_parts = [ - TextContent(type=ContentType.TEXT, text=""), + TextContent(type=ContentType.TEXT, text=" "), ] msg = Message( type=MessageType.MESSAGE, diff --git a/src/copaw/app/channels/dingtalk/handler.py b/src/copaw/app/channels/dingtalk/handler.py index b96d77843..b2c04b1ae 100644 --- a/src/copaw/app/channels/dingtalk/handler.py +++ b/src/copaw/app/channels/dingtalk/handler.py @@ -121,12 +121,14 @@ def _parse_rich_content( # Text may be under "text" or "content" (API variation). item_text = item.get("text") or item.get("content") if item_text is not None: - content.append( - TextContent( - type=ContentType.TEXT, - text=(item_text or "").strip(), - ), - ) + stripped = (item_text or "").strip() + if stripped: + content.append( + TextContent( + type=ContentType.TEXT, + text=stripped, + ), + ) # Picture items may use pictureDownloadCode or downloadCode. dl_code = ( item.get("downloadCode")