Harden WeCom pull streaming and add compatible Dify snapshot refresh configuration#2053
Harden WeCom pull streaming and add compatible Dify snapshot refresh configuration#2053bjhx2003 wants to merge 43 commits intolangbot-app:masterfrom
Conversation
- Reduce stream_poll_timeout from 0.15s to 0.05s for faster response - Change yield condition from % 8 to % 2 for higher push frequency - Skip plugin events for intermediate streaming chunks to reduce latency - Fix yield condition to ensure is_final is always sent - Add msg_id_map cleanup to prevent memory bloat - Update version to 4.9.0-wecom.1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move dependency installation before source code copy to leverage Docker layer caching. Code changes no longer trigger dependency reinstallation, reducing build time from 2-3 minutes to 10-20 seconds. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use `uv sync --no-dev` to exclude dev dependencies - Remove gcc after build with apt-get purge - Clean apt cache with rm -rf /var/lib/apt/lists/* - Expand .dockerignore to exclude docs, tests, and other non-runtime files Image size reduced from 2.07GB to 1.67GB (19% reduction). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 对齐版本号到 4.9.0.post2,并同步 pyproject、包版本与 uv.lock\n- 将企微通道层配置保留在机器人适配器中,新增占位文案延迟配置\n- 将 chunk 批大小与时间窗口下沉到流水线输出配置,补齐默认值与 UI 元数据\n- 将 Dify 流式输出改为 chunk 阈值或时间窗口双触发,并保证 final 立即收口\n- 优化 pull 模式占位文案逻辑,仅在首字超时后返回占位文案\n- 补充企微与 Dify 定向单元测试,覆盖双阈值 flush、占位延迟与最终收口场景
- Add workflow_finished event handling to set is_final=True - Add yielded_final flag to prevent duplicate final chunk yield - Fix WeCom continuous polling issue when Dify workflow ends Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add PullPendingPlaceholderEnabled config option (default: true) - Show delay and content fields only when enabled via visibleOn - Pass effective values to WecomBotClient based on switch state Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add _summarize_stream_text helper for content logging - Add publish/consume action logs with seq, content stats - Track cleared queue items and publish sequence - Help troubleshoot WeCom pull mode polling issues Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add FULL_TEXT and HYBRID search types - Implement RRF (Reciprocal Rank Fusion) for hybrid search - Change add to upsert for idempotent document insertion - Upgrade chromadb dependency to >=1.0.0,<2.0.0 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace hide-exception and block-failed-request-output with exception-handling - Add three strategies: hide, show-hint, show-error - Add failure-hint field for customizable error message - Add database migration dbm021 for config conversion - Remove wecom-stream stage (moved to adapter config) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…tibility - Move filters out of retrieval_settings to avoid empty results - Pass sender_id and session_name in retrieval settings - Some plugins (e.g. LangRAG) pass filters directly to vector_search Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update tests to use adapter config instead of pipeline wecom-stream - Add test for workflow_finished event handling - Add test for ignoring empty message chunks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
感谢 PR!可否提供一下修改前后的截图,例如 配置页面截图、运行效果截图?我们将更快开始 review |
…sessions.publish` call.
|
# Conflicts: # src/langbot/pkg/platform/sources/wecombot.py
| inputs.update(query.variables) | ||
| messsage_idx = 0 | ||
| is_final = False | ||
| stream_completed = False |
There was a problem hiding this comment.
这个参数每一处都是和is_final对应的,为什么不直接用is_final呢
| if rendered_text: | ||
| content_parts.append(rendered_text) | ||
|
|
||
| return ''.join(content_parts) |
|
|
||
| # 如果未开启首字等待占位,则将延迟设为0且占位文案设为空 | ||
| effective_placeholder_delay = pending_placeholder_delay_ms / 1000 if pending_placeholder_enabled else 0 | ||
| effective_placeholder = pending_placeholder if pending_placeholder_enabled else '' |
There was a problem hiding this comment.
这里首字占位,其实我觉着放在creat_message_card这里(主要当时我写钉钉和飞书的时候以为只有卡片流式来着所以函数名就这样了)这样创建首字在进入模型前就能开始,个人感觉比较合理。
| is_stream_mode = await query.adapter.is_stream_output_supported() and has_chunks | ||
|
|
||
| random_delay = random.uniform(*random_range) | ||
| # 流式模式下跳过强制延迟,确保首字快速响应 |
There was a problem hiding this comment.
就像wecom那边我说的,如果是在creat_message_card中创建首字消息,这里就不用这么处理了
|
|
||
| def __init__(self, config: dict, logger: EventLogger): | ||
| enable_webhook = config.get('enable-webhook', True) | ||
| if not enable_webhook: |
|
你好,请问改pr中dify相关的修改的能不能单独提一个pr |
因为好久没有review,我以为你们不搞了,我这边又做了很多处理,所以就合到了同一个分支处理了 @fdc310 |
我的锅,我其实很早就review了并留言,但是忘了推出去 (*꒦ິ⌓꒦ີ),直到前两天 |
@fdc310 了解,不过目前都是纯内存的,对于企业级应用来说没有redis + 单点还是不够稳定 |
|
这块儿我们可以先看看代码再讨论,企业级的功能确实是我们目前方向
…------------------ Original ------------------
From: 夜雨 ***@***.***>
Date: Mon,Mar 30,2026 5:55 PM
To: langbot-app/LangBot ***@***.***>
Cc: Junyan Chin ***@***.***>, Mention ***@***.***>
Subject: Re: [langbot-app/LangBot] Harden WeCom pull streaming and addcompatible Dify snapshot refresh configuration (PR #2053)
bjhx2003 left a comment (langbot-app/LangBot#2053)
你好,请问改pr中dify相关的修改的能不能单独提一个pr
因为好久没有review,我以为你们不搞了,我这边又做了很多处理,所以就合到了同一个分支处理了 @fdc310
我的锅,我其实很早就review了并留言,但是忘了推出去 (*꒦ິ⌓꒦ີ),直到前两天
@fdc310 我尝试看看能不能拆开吧,因为后面我对微信客服接入和 企微应用接管微信客服处理方面都做了改造,还引入了redis,整体是一个比较大的动作。
好的,感谢。如果可以的话尽量每一块开一个分支,包括您这边提到的位置客服,企微应用和redis相关的都单独pr,然后我们这边的话暂时还没有使用redis的规划,可能暂时不会引入
@fdc310 了解,不过目前都是纯内存的,对于企业级应用来说没有redis + 单点还是不够稳定
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
update:合并群聊模式下userid的生成
概述 / Overview
本次 PR 主要增强了企业微信智能机器人 Pull 模式下的流式消息处理能力,并补齐 Dify 流式快照刷新配置,同时保持默认行为尽量兼容 master。
This PR mainly improves pull-mode streaming for the WeCom AI bot, adds Dify snapshot refresh configuration, and keeps default behavior as compatible with master as possible.
主要改动 / Key changes
增强企微 Pull 流式生命周期处理
Harden WeCom pull streaming lifecycle
改进企微回复与流水线流式处理
respback在流式模式下跳过强制延迟,提升首字响应速度is_final标记,避免 finish 状态错误Improve streaming response handling in pipeline stages
优化企微消息转换
WecomBotMessageConverter在转文本时保留引用内容Improve WeCom message conversion
补齐 Dify 流式快照刷新策略
output.dify-stream.chunk-batch-sizeoutput.dify-stream.flush-window-enabledoutput.dify-stream.flush-window-msworkflow_finished场景,保证流式输出能正确 finishAdd Dify snapshot refresh strategy
output.dify-stream.chunk-batch-sizeoutput.dify-stream.flush-window-enabledoutput.dify-stream.flush-window-msworkflow_finishedcorrectly to ensure stream completion配置迁移与兼容默认值
dify-service-api作为 runner 时显示dify-stream配置项500ms8Config migration and compatibility defaults
dify-streamsection only when the selected runner isdify-service-api500ms8Docker 构建优化
.dockerignoreDockerfile复制顺序与依赖安装顺序,尽量利用 Docker 层缓存Docker build optimization
.dockerignoreDockerfilelayer usage for better build caching测试
Tests
更改前后对比截图 / Screenshots
检查清单 / Checklist
已通过以下测试: