180 Commits

Author SHA1 Message Date
countbot-ai af94db9329 Merge pull request #115 from ddggkkcc/pr/rag-crag-refusal
[Feature] Wiki 块级问答增加评估路由与诚实拒答(CRAG 式):知识库没有答案时不再硬答
2026-09-04 12:02:02 +08:00
countbot-ai a16da4ae2f Merge pull request #114 from ddggkkcc/pr/rag-per-doc-cap
[Feature] RAG 检索结果按文档去重(max_per_doc):修复跨文档问题的来源单一化
2026-09-04 12:01:53 +08:00
countbot-ai 0dc764d6a9 Merge pull request #109 from ddggkkcc/pr/wiki-chunk-retrieval-v1
[Feature] Wiki 检索增强:按标题分块(chunk-level retrieval)——更准、更省 token
2026-09-04 12:01:29 +08:00
countbot-ai 8688b9f0cc Merge pull request #111 from ddggkkcc/pr/restore-jieba
[Fix] 恢复 requirements.txt 中被注释的 jieba:修复默认安装的中文分词降级
2026-09-04 12:01:14 +08:00
countbot-ai 37866cb4d0 Merge pull request #116 from ddggkkcc/audit/armin-main
fix(Agent): 移除系统提示词中的动态内容以稳定 prompt cache 前缀
2026-09-04 09:42:48 +08:00
RIC f58446cae4 修复(Agent): 移除系统提示词中的动态内容以稳定 prompt cache 前缀
- _get_identity() 仅保留配置驱动的静态身份文本,不再注入当前时间与用户称呼/地址/输出语言

- session_summary、channel/chat_id/account_id 不再拼入 system prompt,避免前缀随会话变化

- 新增 _build_dynamic_user_context(),将上述信息类动态内容统一注入首条 user 消息

- team_reminder 保持注入 system 消息的既有行为(指令类内容,独立议题)

- 新增 tests/test_prompt_cache_stability.py 回归测试
2026-09-03 21:27:10 +08:00
RIC 235c6c0e78 feat(rag): corrective routing for chunk-level ask - grade, rewrite, refuse
Chunk-level ask used to inject the top-6 chunks into the generation
prompt unconditionally. On the 60-question eval, all 10 negative
questions (answer not in the corpus) were still answered, and the
top-1 BM25 scores of negatives overlap 7/10 with positives, so no
score threshold can gate this reliably.

The ask path now routes through a lightweight LLM grader (single call,
~200-400 tokens) before generation:
- all relevant -> generate as before
- partially relevant -> filter to the graded-relevant chunks, generate
- none relevant -> rewrite the query once with LLM, re-search and
  re-grade; still none -> refuse explicitly instead of hallucinating

Every LLM step degrades safely: no provider, grading failure or
unparseable output falls back to the previous plain-generation
behaviour, so nothing breaks when the flag is on but no provider is
configured.

Only active under COUNTBOT_RAG_CHUNKS=1. No new dependencies.

Tests: 12 new (three-way routing, refusal after one rewrite, retry
succeeds, grading failure/unparseable/no-provider fallbacks, grader
output parsing contract). Full suite: 138 passed.

Refs: #107
2026-09-03 20:46:11 +08:00
RIC 799569e5a2 feat(rag): cap chunks per document in search results (max_per_doc=1)
With chunk-level retrieval the top-k list can be monopolised by
several high-scoring chunks of the same document: on the 52-doc eval
corpus, collecting 10 distinct documents required scanning 25.3 chunks
on average, starving multi-doc questions of sources.

search()/search_chunks() now oversample (top_k * 5), keep at most
max_per_doc chunks per document first, then backfill by score if the
result list is short - so small knowledge bases keep full top_k while
large ones gain source diversity.

Measured on the 60-question eval (production top-6 injection):
- cross-doc source coverage: 0.500 -> 0.556
- paraphrased-question hit: 0.600 -> 0.700
- overall positive hit: 0.800 -> 0.829
- single-doc / needle / cross hit: no regression
max_per_doc<=0 restores the previous behaviour exactly.

Tests: 4 new (front-cap respected, backfill keeps result count, cap
disabled falls back to legacy ranking, top_k and ordering preserved).
Full suite: 126 passed.

Refs: #107
2026-09-03 17:47:27 +08:00
RIC 28b635177a fix(deps): un-comment jieba so default installs get word-level CJK tokenization
BM25Index already supports jieba and falls back to per-character
tokenization when it is missing. Because the dependency was commented
out, a default 'pip install -r requirements.txt' silently ran the
degraded path, so the wiki search quality users actually get is well
below what the code (and our published eval numbers in #107) assume.

Measured impact on the 60-question eval (with vs without jieba):
- direct-question recall@5: 0.80 -> 0.53
- paraphrased-question recall@5: 0.20 -> 0.10 (no top-1 hit at all)
- exact-fact recall@10: 1.00 -> 0.80

One-line change, no code changes: the graceful fallback stays for
anyone who deliberately removes it.

Refs: #107
2026-09-03 17:13:12 +08:00
RIC 1175bfe7a9 bench(wiki-rag): reproducible 60-question doc-vs-chunk evaluation harness
Three scripts + 60 hand-annotated questions over the public
countbot.cn/docs corpus (52 pages, fetched by fetch_corpus.py):

- run_g0.py: doc-level BM25 baseline (pre-change behaviour)
- run_g1.py: chunk-level BM25 (this PR) on the same questions
- fetch_corpus.py: downloads the public corpus into rag-bench/corpus/

Pure programmatic scoring (recall@k / MRR@10 / NDCG@10 / top1 /
injected-token volume), no LLM judge, no private data. The headline
numbers quoted in the PR description come from running these on the
same corpus/questions before and after the chunk change.

Refs: #107
2026-09-03 16:01:51 +08:00
RIC 7b4ba2be6d feat(wiki): chunk-level retrieval with section provenance, behind COUNTBOT_RAG_CHUNKS
Splits each wiki doc by Markdown headings (long sections re-split by
paragraph with overlap; code fences kept intact) and indexes every chunk
as a small doc on the existing BM25Index - no algorithm rewrite, no new
third-party dependencies.

Retrieval unit changes from whole doc to chunk (same 60-question eval):
- context injected: 12,334 -> 910 est tokens avg (-92.6%)
- direct-question top1: 0.067 -> 0.533; production hit rate 56% -> 82%
- every result carries [slug#section] provenance (was 0%)

Default off (COUNTBOT_RAG_CHUNKS=1 to enable); unset behaves exactly as
before, verified by switch-OFF regression tests. AgentLoop,
ToolRegistry and Cron are untouched. Chunk index is a derived artifact
(workspace/wiki/chunk_index.json), deletable and rebuildable.

Tests: tests/rag/ 34 new; full suite passes.

Refs: #107
2026-09-03 15:58:17 +08:00
countbot-ai 969b800677 Merge pull request #98 from ddggkkcc/feature-external-coding-tool-dsh
feat(external-agents): add dsh profile for DeepSeek Harness headless
2026-08-27 15:45:35 +08:00
countbot-ai 44383c1b4f Merge pull request #101 from Liears/fix/wiki-shared-provider
修复(Wiki): 补充缺失的 get_shared_provider,恢复 ask/compile 的 LLM 调用
2026-08-27 15:45:29 +08:00
Neon c4ffccd56f 修复(Wiki): 补充缺失的 get_shared_provider,恢复 ask/compile 的 LLM 调用
Wiki 的三个 LLM 调用点(Agent 工具 ask、REST /wiki/ask、REST /wiki/compile)
都通过 from backend.app import get_shared_provider 获取共享 provider,但该函数
从未在 backend.app 中定义——provider 实际存放在 app.state.shared["provider"]。

ImportError 被调用方的 except Exception 静默吞掉,导致:
- ask 永远走检索结果拼接回退,不产生自然语言回答
- compile 永远原样返回未编译内容
- 日志无任何报错,难以察觉

修复:在 backend.app 中按 get_tool_registry 的既有模式补充
get_shared_provider();lifespan 启动前返回 None 由调用方降级。
调用点无需改动。附回归测试。
2026-08-21 10:15:16 +08:00
Neon f8c69e73dc Merge branch 'countbot-ai:main' into main 2026-08-20 21:12:00 +08:00
RIC 82be975d28 feat(external-agents): add dsh profile for DeepSeek Harness headless 2026-08-17 15:26:59 +08:00
w 1750c50c26 docs: update project status and default locale 2026-08-11 17:23:17 +08:00
w 22caceae3e chore: bump application version to 9.01 v0.9.1 2026-08-11 16:29:23 +08:00
w f2d9e44245 chore: update CountBot domain references 2026-08-11 16:26:28 +08:00
w 723167d3c5 fix: collapse workflow reasoning in final responses 2026-08-11 15:40:05 +08:00
countbot-ai 2a9def3602 文档(README): 更新文档 2026-07-15 21:10:30 +08:00
countbot-ai ee910a8338 Merge pull request #94 from hhzscreate/main
skill解析能力适配:skill加载改为yaml解析器,写入使用safe_dump
2026-07-15 21:07:12 +08:00
hhzscreate 47d682b1b3 skill解析能力适配最新skill标准,不使用逐行split。 2026-07-14 18:17:03 +08:00
countbot-ai f4fe5a4ba1 Merge pull request #93 from hhzscreate/main
修复工具会话上下文被并发消息覆盖,导致把 A 用户生成的文件/图片发到 B 的聊天。
2026-07-14 15:54:42 +08:00
hhzscreate fb181c9fe5 修复工具会话上下文被并发消息覆盖,导致把 A 用户生成的文件/图片发到 B 的聊天。 2026-07-14 15:06:51 +08:00
countbot-ai 7e2fa621de Merge pull request #92 from hhzscreate/main
修复ISSUE #90 相关mcp失败问题
2026-07-14 11:52:28 +08:00
hhzscreate c16175e4f4 修复以下问题:
(1)新增 MCP server 工具数为 0,其原因为重连块被误缩进进工具清理循环
(2)测试连接成功、但持久连接 0 tools ,mcp连接在 A 任务打开、B 任务关闭,违反 anyio 同任务约束。改为每个 server 由“持有者任务”独占 open/hold/close。
(3)中途改 MCP 配置,老对话不加载新工具,改为每轮对话前全量对齐(增/删/换)。
(4)停止后全局开关仍开,状态轮询把它又连回来。导致无法手动单独停止server。改为停止后全局开关仍开,状态轮询把它又连回来
2026-07-12 00:56:47 +08:00
countbot-ai f0ee0b2d1d Merge pull request #91 from hhzscreate/main
fix:修复用户在两次请求之间改了 Key 配置,导致同线程获取相同的不可重入锁导致的死锁。
2026-07-10 16:40:51 +08:00
hhzscreate 06e743794a 修复用户在两次请求之间改了 Key 配置,导致同线程获取相同的不可重入锁导致的死锁。 2026-07-06 11:31:48 +08:00
countbot-ai 62486dd86e Merge pull request #89 from ranpis02/patch-1
fix(cron): 修复频道定时任务执行失败
2026-06-01 12:42:30 +08:00
Ranpis Jump 644a907998 Refactor CronExecutor with improved structure 2026-05-31 23:32:31 +08:00
Ranpis Jump 7273431535 fix(cron): 修复频道定时任务执行失败
定时任务在配置 channel/chat_id 并生成 Agent 回复后,会进入频道会话创建或更新逻辑。该逻辑使用 json.loads/json.dumps 处理 channel_context,但 cron executor 模块缺少 json import,导致任务报错 name 'json' is not defined。

补充 json import,使定时任务可以正常保存频道上下文并继续投递消息。
2026-05-31 23:27:08 +08:00
countbot-ai 6b37c72d9b 文档(README): 更新文档
文档(README): 更新文档
2026-05-08 10:19:52 +08:00
countbot-ai 930210822c 构建(依赖): 修复Wiki模块
构建(依赖): 修复编译版Wiki 500报错
2026-05-06 07:43:53 +08:00
w 6dc718924e 构建(依赖): 修复编译版Wiki 500报错
- requirements.txt: 新增 python-frontmatter 和 PyYAML(Wiki核心依赖)
- build-desktop.yml: 补全第三方库 hidden-import
  - yaml (frontmatter依赖)
  - bs4, croniter, httpx, anthropic, openai
  - loguru, pydantic, pydantic.deprecated
  - sqlalchemy, aiosqlite, websockets
2026-05-06 07:41:53 +08:00
countbot-ai 535328e892 构建(pyinstaller): 补全所有缺失的hidden-import模块
构建(pyinstaller): 补全所有缺失的hidden-import模块
2026-05-06 01:16:41 +08:00
w 6a107ae591 构建(pyinstaller): 补全所有缺失的hidden-import模块
- Wiki知识库: api.wiki, modules.wiki.*, frontmatter
- MCP客户端: api.mcp, modules.mcp.*
- 多智能体: api.agent_teams, modules.agent.*, models.agent_team
- 用户/安全: modules.auth.*
- IM渠道: modules.channels.*
- 配置管理: modules.config.*
- 编程工具: modules.tools.*
- 记忆/会话: modules.session.*
- 工作区: modules.workspace.*
- 定时任务: modules.cron.*
- LLM提供者: modules.providers.*
- 消息队列: modules.messaging.*
- WebSocket: modules.websocket.*
- 系统托盘: modules.system.*
- 第三方库: frontmatter, python_multipart

构建(依赖): 默认禁用jieba分词(41MB体积对小知识库提升约0%)

搜索(wiki): 扩展停用词表并优化分词策略文档
2026-05-06 01:14:52 +08:00
countbot-ai 16f115f014 发布(0.9.0): 新增MCP客户端与Wiki知识库模块
合并 develop 分支到 main,包含 v0.9.0 全部更新:
- 新增 MCP 客户端模块(默认关闭)
- 新增 Wiki 知识库模块
- WebSocket 状态广播
- API Key 轮换机制
- 心跳问候逻辑简化
- 前端管理面板与国际化支持
2026-05-05 21:18:02 +08:00
w e61f644981 构建(依赖): 将MCP客户端与jieba分词设为正式依赖 2026-05-05 21:07:33 +08:00
w 02d67a3816 依赖(可选): 新增MCP客户端与Wiki中文分词可选依赖 2026-05-05 21:04:11 +08:00
w 12e2abc277 依赖(可选): 新增MCP客户端与Wiki中文分词可选依赖 2026-05-05 21:01:29 +08:00
w eb0b110995 文档(releases): 新增v0.9.0发布说明并同步README更新 2026-05-05 16:54:34 +08:00
w fca09faf95 优化(注释): 清理无关引用并简化心跳问候逻辑 v0.9.0 2026-05-05 16:23:06 +08:00
w 7093df13f6 发布(0.9.0): 更新版本号 2026-05-05 09:42:08 +08:00
w ed2d9f09d3 构建(前端): 更新 dist 构建产物与源码重构 2026-05-05 09:36:13 +08:00
w 91a08b9c28 优化(tools): 完善工具注册与初始化流程 2026-05-05 09:36:08 +08:00
w 98505b189c 优化(agent): 改进上下文管理与心跳机制 2026-05-05 09:36:02 +08:00
w cbebb8e361 增强(websocket): 新增MCP状态广播模块 2026-05-05 09:35:57 +08:00
w 88a8fa3cb2 功能(wiki): 新增知识库模块与BM25搜索能力 2026-05-05 09:35:51 +08:00
w d6194e96b5 功能(mcp): 新增MCP客户端模块与API端点 2026-05-05 09:35:40 +08:00