From e675a81bd8445805793b945623a6d084dddb31c3 Mon Sep 17 00:00:00 2001 From: Hyu Date: Sat, 10 Oct 2026 21:29:47 +0800 Subject: [PATCH] fix(dingtalk): make card replies switch control streaming and settings --- src/langbot/libs/dingtalk_api/api.py | 2 + .../platform/adapters/dingtalk/manifest.yaml | 38 +++++++++++++------ .../pkg/platform/sources/dingtalk.yaml | 38 +++++++++++++------ 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/src/langbot/libs/dingtalk_api/api.py b/src/langbot/libs/dingtalk_api/api.py index f5f50933b..7d712497e 100644 --- a/src/langbot/libs/dingtalk_api/api.py +++ b/src/langbot/libs/dingtalk_api/api.py @@ -76,6 +76,8 @@ def _stringify_card_param_map(card_param_map: Optional[dict]) -> dict: def is_stream_card_configured(config: dict) -> bool: + if not config.get('markdown_card', True): + return False template_id = config.get('card_template_id') # Older manifests stored instructional placeholder text as the default. return isinstance(template_id, str) and bool(template_id.strip()) and template_id.strip() != '填写你的卡片template_id' diff --git a/src/langbot/pkg/platform/adapters/dingtalk/manifest.yaml b/src/langbot/pkg/platform/adapters/dingtalk/manifest.yaml index fd288ff14..24adcb857 100644 --- a/src/langbot/pkg/platform/adapters/dingtalk/manifest.yaml +++ b/src/langbot/pkg/platform/adapters/dingtalk/manifest.yaml @@ -50,19 +50,39 @@ spec: type: string required: true default: "" + - name: markdown_card + label: + en_US: Use Card Replies + zh_Hans: 使用卡片回复 + zh_Hant: 使用卡片回覆 + description: + en_US: Controls Markdown and streaming card replies. Disable to use plain text while keeping your template settings. When enabled, a configured template automatically enables streaming. + zh_Hans: 控制 Markdown 和流式卡片回复。关闭后使用纯文本,保留模板配置;开启且已配置模板时自动使用流式回复。 + zh_Hant: 控制 Markdown 和串流卡片回覆。關閉後使用純文字,保留範本設定;開啟且已設定範本時自動使用串流回覆。 + type: boolean + required: false + default: true - name: card_template_id + show_if: + field: markdown_card + operator: eq + value: true label: en_US: Card Template ID zh_Hans: 卡片模板ID zh_Hant: 卡片範本ID description: - en_US: Template for streaming text replies. Save and publish it in DingTalk Card Platform, then paste its ID here to automatically enable streaming replies. Leave empty for ordinary replies. Separate from the human input template. - zh_Hans: 用于流式文字回复。在钉钉卡片平台保存并发布模板后,填写 ID 即自动启用流式回复,留空使用普通回复;与人工输入卡片模板分开配置。 - zh_Hant: 用於串流文字回覆。在釘釘卡片平台儲存並發布範本後,填寫 ID 即自動啟用串流回覆,留空使用一般回覆;與人工輸入卡片範本分開設定。 + en_US: Template for streaming text replies. Save and publish it in DingTalk Card Platform, then paste its ID here to automatically enable streaming while card replies are enabled. Leave empty for ordinary replies. Separate from the human input template. + zh_Hans: 用于流式文字回复。在钉钉卡片平台保存并发布模板后,开启卡片回复后,填写 ID 即自动启用流式回复,留空使用普通回复;与人工输入卡片模板分开配置。 + zh_Hant: 用於串流文字回覆。在釘釘卡片平台儲存並發布範本後,開啟卡片回覆後,填寫 ID 即自動啟用串流回覆,留空使用一般回覆;與人工輸入卡片範本分開設定。 type: string required: false default: "" - name: stream_card_template_download + show_if: + field: markdown_card + operator: eq + value: true label: en_US: Download Streaming Reply Card Template zh_Hans: 下载流式回复卡片模板 @@ -76,15 +96,11 @@ spec: default: '' url: /api/v1/platform/adapters/dingtalk/stream-card-template download_filename: dingtalk_stream_card.json - - name: markdown_card - label: - en_US: Markdown Card - zh_Hans: 是否使用 Markdown 卡片 - zh_Hant: 是否使用 Markdown 卡片 - type: boolean - required: false - default: true - name: card_auto_layout + show_if: + field: markdown_card + operator: eq + value: true label: en_US: Card Auto Layout zh_Hans: 卡片宽屏自动布局 diff --git a/src/langbot/pkg/platform/sources/dingtalk.yaml b/src/langbot/pkg/platform/sources/dingtalk.yaml index d604985f1..43392cf0b 100644 --- a/src/langbot/pkg/platform/sources/dingtalk.yaml +++ b/src/langbot/pkg/platform/sources/dingtalk.yaml @@ -49,19 +49,39 @@ spec: type: string required: true default: "" + - name: markdown_card + label: + en_US: Use Card Replies + zh_Hans: 使用卡片回复 + zh_Hant: 使用卡片回覆 + description: + en_US: Controls Markdown and streaming card replies. Disable to use plain text while keeping your template settings. When enabled, a configured template automatically enables streaming. + zh_Hans: 控制 Markdown 和流式卡片回复。关闭后使用纯文本,保留模板配置;开启且已配置模板时自动使用流式回复。 + zh_Hant: 控制 Markdown 和串流卡片回覆。關閉後使用純文字,保留範本設定;開啟且已設定範本時自動使用串流回覆。 + type: boolean + required: false + default: true - name: card_template_id + show_if: + field: markdown_card + operator: eq + value: true label: en_US: card template id zh_Hans: 卡片模板ID zh_Hant: 卡片範本ID description: - en_US: Template for streaming text replies. Save and publish it in DingTalk Card Platform, then paste its ID here to automatically enable streaming replies. Leave empty for ordinary replies. Separate from the human input template. - zh_Hans: 用于流式文字回复。在钉钉卡片平台保存并发布模板后,填写 ID 即自动启用流式回复,留空使用普通回复;与人工输入卡片模板分开配置。 - zh_Hant: 用於串流文字回覆。在釘釘卡片平台儲存並發布範本後,填寫 ID 即自動啟用串流回覆,留空使用一般回覆;與人工輸入卡片範本分開設定。 + en_US: Template for streaming text replies. Save and publish it in DingTalk Card Platform, then paste its ID here to automatically enable streaming while card replies are enabled. Leave empty for ordinary replies. Separate from the human input template. + zh_Hans: 用于流式文字回复。在钉钉卡片平台保存并发布模板后,开启卡片回复后,填写 ID 即自动启用流式回复,留空使用普通回复;与人工输入卡片模板分开配置。 + zh_Hant: 用於串流文字回覆。在釘釘卡片平台儲存並發布範本後,開啟卡片回覆後,填寫 ID 即自動啟用串流回覆,留空使用一般回覆;與人工輸入卡片範本分開設定。 type: string required: false default: "" - name: stream_card_template_download + show_if: + field: markdown_card + operator: eq + value: true label: en_US: Download Streaming Reply Card Template zh_Hans: 下载流式回复卡片模板 @@ -75,15 +95,11 @@ spec: default: '' url: /api/v1/platform/adapters/dingtalk/stream-card-template download_filename: dingtalk_stream_card.json - - name: markdown_card - label: - en_US: Markdown Card - zh_Hans: 是否使用 Markdown 卡片 - zh_Hant: 是否使用 Markdown 卡片 - type: boolean - required: false - default: true - name: card_auto_layout + show_if: + field: markdown_card + operator: eq + value: true label: en_US: Card Auto Layout zh_Hans: 卡片宽屏自动布局