Commit Graph

1400 Commits

Author SHA1 Message Date
明天好像没什么
92d5b096c8 chore(deps): 精简依赖并升级Python基线至3.11
- 移除3.10兼容层,清理旧版本wheel与回退包
- 统一numpy、scipy、networkx为单版本,削减重复解析
- 新增mcp>=0.9.0与sse-starlette>=2.2.1,解锁新能力
- inkfox升至0.1.1,新增arm64/aarch64原生支持
- 通过更严格的平台标记,锁文件体积减少八成
2025-10-18 20:11:17 +08:00
minecraft1024a
c9c2de40ee chore(scripts): 移除过时的一次性脚本
移除了两个用于项目重构的一次性脚本:
- `convert_sqlalchemy_models.py`:用于将 SQLAlchemy 模型从旧版 `Column` 语法转换为 `Mapped` 语法。
- `update_prompt_imports.py`:用于批量更新 `Prompt` 类的导入路径。

这些脚本已完成其历史使命,不再需要维护。

同时,对插件加载日志和 manifest 转换脚本进行了小幅改进:
- 插件加载日志现在会显示组件的简短描述,方便快速了解其功能。
- manifest 转换脚本增加了对更多元数据字段(如仓库地址、关键字、分类等)的支持。
2025-10-18 19:22:34 +08:00
tt-P607
e702480411 Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-18 17:09:35 +08:00
tt-P607
373db77768 Revert "总之就是知识库"
This reverts commit 0383a999fb.
2025-10-18 17:09:18 +08:00
LuiKlee
bafddb39e8 调整格式 2025-10-18 12:08:21 +08:00
minecraft1024a
efded9b03a Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-18 11:13:54 +08:00
minecraft1024a
8c97774465 ruff ci 2025-10-18 11:11:05 +08:00
tt-P607
72ea362e29 feat(web_search): 新增 Metaso 搜索引擎支持
为联网搜索工具集成了新的搜索引擎 Metaso,为用户提供更多搜索选择。

- 在搜索引擎基类 `BaseSearchEngine` 中添加了可选的 `read_url` 方法,为未来支持直接读取网页内容奠定基础。
- 更新了插件加载、工具执行逻辑和配置文件模板,以完整支持 Metaso 引擎。
- 将默认回复生成器的任务超时时间从 15 秒延长至 45 秒,以适应联网搜索等耗时较长的操作,提高稳定性。
2025-10-18 00:46:17 +08:00
minecraft1024a
39e672a1d5 docs: 更新 README.md 中的功能描述和 admonition 语法
- 将 admonition 语法从 `[!docs: 更新 README.md 功能描述和 admonition 语法

- 将 admonition 语法从 `[!IMPORTANT]` 和 `[!WARNING]` 调整为 GitHub 支持的 `[IMPORTANT]` 和 `[WARNING]` 格式。
- 在“拓展功能”部分新增了“AFC 智能对话”特性。
- 移除了“原版功能”中重复列出的“智能对话系统”条目,使其更加清晰。
2025-10-17 21:25:26 +08:00
minecraft1024a
afeac77d1c docs(config): 更新配置文件注释说明
将配置类继承说明从“重要的”改为“所有”,以强调所有配置类都必须继承自 `ValidatedConfigBase`。
2025-10-17 21:20:43 +08:00
minecraft1024a
8c17a22947 现在不是空盒子了 2025-10-17 21:15:12 +08:00
minecraft1024a
7c4af00b62 fix(server): 移除启动日志中多余的协议前缀 2025-10-17 21:07:34 +08:00
minecraft1024a
fb1e4ff110 Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-17 20:25:47 +08:00
minecraft1024a
0b5a536855 chore(scripts): 移除无用的脚本文件
删除了两个已不再需要的脚本:
- `run_multi_stage_smoke.py`: 用于早期烟雾测试,现已过时。
- `text_length_analysis.py`: 用于分析数据库中的消息文本长度,功能已不再需要。

feat(scripts):为来自MaiBot的插件提供了转换插件的 _manifest.json 文件的脚本
2025-10-17 20:25:44 +08:00
Windpicker-owo
6eb6bab4df Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-17 20:16:27 +08:00
Windpicker-owo
f22e6365cc feat(action): 重构 Action 激活机制并添加 go_activate() 方法
引入新的 Action 激活机制,允许通过重写 go_activate() 方法来自定义激活逻辑。提供了三个工具函数:
- _random_activation(): 随机概率激活
- _keyword_match(): 关键词匹配激活
- _llm_judge_activation(): LLM 智能判断激活

主要变更:
- 在 BaseAction 中添加 go_activate() 抽象方法和相关工具函数
- 更新 ActionModifier 使用新的激活判断逻辑
- 在 hello_world_plugin 中添加新的激活方式示例
- 更新文档说明新的激活机制
- 保持向后兼容,旧的激活类型配置仍然可用

BREAKING CHANGE: Action 激活判断现在通过 go_activate() 方法进行,旧的激活类型字段已标记为废弃但仍然兼容
2025-10-17 20:16:15 +08:00
minecraft1024a
9e39d28e80 fix(chat): 修复睡眠和情绪系统中的空值和逻辑问题
修复了两个问题:
1.  在睡眠状态下,如果没有设置起床时间,且当天也无法从日程中获取新的起床时间,程序会错误地继续执行后续的唤醒判断逻辑,而不是直接返回并继续睡眠。
2.  在更新情绪状态时,如果消息的`interest_value`为`None`,会导致类型错误。已增加空值检查,将其默认处理为 0.0。
2025-10-17 20:04:12 +08:00
minecraft1024a
02a54fd3c9 feat(chat): 引入睡眠系统,在睡眠状态下拦截消息
在消息处理的最前端 (`MessageManager`) 增加了对睡眠状态的检查。当系统处于 `SLEEPING` 状态时,将直接拦截所有新消息,不再进行后续处理。

同时,为了配合睡眠系统的正常运作:
- 将睡眠系统的定时任务初始化移至 `main.py`,确保其在应用启动时正确加载。
- 在主动思维插件 (`proactive_thinker`) 的定时任务(冷启动和日常唤醒)中增加了睡眠状态检查,避免在睡眠期间触发主动行为。
2025-10-17 19:55:11 +08:00
minecraft1024a
1eade97633 refactor(config): 简化睡眠系统配置项
移除旧的、基于睡眠压力模型的多个配置项,包括睡眠压力阈值、失眠概率(区分不同压力)、压力增减值等。

这些配置项在新系统中已不再使用,将其移除可以简化配置文件,避免引起混淆。现在的睡眠逻辑更加直接,不再依赖复杂的压力计算。
2025-10-17 19:04:52 +08:00
minecraft1024a
559ad03fe0 refactor(chat): 从 MessageManager 中移除睡眠和唤醒管理器的残留代码
在之前的提交 (cb51446) 中,睡眠管理器模块已被移除。本次提交清除了 `MessageManager` 中与之相关的残留代码,包括导入语句、实例初始化以及启动/停止逻辑,完成了整个重构过程。
2025-10-17 19:02:49 +08:00
minecraft1024a
cb514465a2 refactor(chat): 移除旧的睡眠管理器模块
删除了位于 `src/chat/message_manager/sleep_manager/` 目录下的整个旧版睡眠管理器。该模块包含了 `sleep_manager`, `wakeup_manager`, `sleep_state` 等多个文件,其功能将被新的实现所取代。

同时,对 `context_manager.py` 中的群聊判断逻辑进行了微调,以适应新的消息结构。
2025-10-17 18:57:59 +08:00
minecraft1024a
ff3b35a5d3 Revert "实现了新的睡眠系统喵~",我看了不如我回去自己写一个()
This reverts commit e1dde64fc6.
2025-10-17 18:44:38 +08:00
tt-P607
ce3fe95b37 refactor(core): make chat utils async and decouple plugin dependencies
- Convert `get_recent_group_speaker` and `count_messages_between` in `chat/utils` to async functions to align with underlying asynchronous database calls, preventing potential blocking issues.

- Implement optional import for `sleep_system` within the `affinity_flow_chatter` plugin using a try-except block. This decouples the hard dependency between the two plugins, enhancing modularity and ensuring the chatter plugin remains operational even if the sleep system is unavailable.
2025-10-17 14:44:33 +08:00
tt-P607
d3b38f49b4 Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-17 14:21:42 +08:00
tt-P607
c51d72b945 feat(chat): add protection for quoted content in response processing
In the LLM response post-processing flow, a new protection layer for quoted content has been added. This prevents the sentence splitter from incorrectly breaking up complete sentences enclosed in quotation marks, thus ensuring the integrity of the quoted text.

- Adds `protect_quoted_content` and `recover_quoted_content` functions.
- Upgrades the response processing to a three-layer protection system (kaomoji, quotes, special blocks).
- Also adjusts the default values for typing simulation time to improve user experience.
2025-10-17 14:21:32 +08:00
ikun-11451
e68b805cfb 修复了导入错误喵...... 2025-10-17 12:05:28 +08:00
tt-P607
aa35581cbc Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-17 02:34:51 +08:00
tt-P607
1f26238368 refactor(chat): overhaul response processing for robustness and integrity
This commit redesigns the LLM response handling pipeline to gracefully manage complex, long, and structured outputs, shifting from a restrictive filtering model to a more resilient and content-aware approach.

The previous implementation suffered from brittleness, often discarding valid responses or corrupting formatted content. This refactor introduces two core changes to ensure response integrity:

1.  **Adaptive Message Merging:** Replaces the rigid message count and length limits, which caused the silent dropping of valid long-form answers. The new logic dynamically merges the shortest adjacent sentences if a response is overly fragmented, ensuring the full thought is preserved while adhering to display limits.

2.  **Content-Aware Pre-processing:** Implements a protection mechanism for special text formats. It now identifies and isolates Markdown code blocks, LaTeX-style math equations, and other code-like segments using placeholders before splitting or typo generation. This prevents formatting corruption and ensures technical content is rendered correctly.

Additionally, the LLM prompt for splitting has been refined to emphasize logical coherence over simple fragmentation.

Finally, this commit also hardens the `LLMRequest` class against race conditions by adding an `asyncio.Lock` to serialize generation requests, improving the system's stability under concurrent workloads.
2025-10-17 02:34:39 +08:00
ikun-11451
f57d0f3213 Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-17 01:48:06 +08:00
ikun-11451
e1dde64fc6 实现了新的睡眠系统喵~ 2025-10-17 01:47:43 +08:00
tt-P607
514da0b56f Merge branch 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-17 01:09:36 +08:00
tt-P607
59e94ea7aa 嗯,llm分割提示词优化一下 2025-10-17 01:09:08 +08:00
LuiKlee
bfbba6879c 修复格式问题
修改613行的标点
如果功能异常,请提交报告
2025-10-16 20:28:15 +08:00
LuiKlee
bd864b43ab Update README.md 2025-10-15 23:39:59 +08:00
LuiKlee
7601f881fc Update README.md 2025-10-15 23:34:29 +08:00
LuiKlee
f587565502 调整 2025-10-15 23:33:06 +08:00
LuiKlee
ea95d56177 调整排版 2025-10-15 23:28:45 +08:00
ikun两年半
21e4f7f659 更正依赖名字喵~ 2025-10-13 17:43:40 +08:00
tt-P607
109aef4623 feat(chat): 实现延迟重处理并修复并发问题
本次提交为聊天处理逻辑带来了两项关键改进:

1.  **中断后的延迟重处理:**
    当机器人被新消息打断时,系统现在会等待一个短暂的延迟(例如0.5秒)再重新处理。这允许多条快速连续发送的消息被合并到同一次处理中,避免了因消息轰炸导致的多次、零碎的处理流程,提高了效率和响应的连贯性。

2.  **为聊天器添加并发锁:**
    在 `AffinityChatter` 中引入了 `asyncio.Lock`,以确保每个实例一次只处理一个流上下文。这可以防止在并发场景下可能出现的竞争条件,保证了数据处理的原子性和状态的一致性。
2025-10-13 09:22:57 +08:00
ikun-11451
95959b2c16 将获取方式改成get喵~ 2025-10-12 22:12:20 +08:00
LuiKlee
dc1a919eda 减少 .env 文件的重复读取
只在开始时加载一次.env,后续从 os.environ 读取
2025-10-12 20:53:15 +08:00
minecraft1024a
dcd7e27cdc Merge branches 'dev' and 'dev' of https://github.com/MoFox-Studio/MoFox_Bot into dev 2025-10-12 14:28:58 +08:00
LuiKlee
cae9026ea1 添加重试机制
如果 ui_logger 服务 长期不可用,该版本会多尝试几次,可能增加少量 CPU 开销
3次重试 + 0.1s 间隔
2025-10-12 14:28:58 +08:00
minecraft1024a
4ded724f49 chore(chatter): 添加关于迁移逻辑的 TODO 注释 2025-10-12 14:28:22 +08:00
minecraft1024a
adfe15a10f **我撞到dict了 2025-10-12 14:25:02 +08:00
minecraft1024a
54c75a1930 Revert "refactor(chatter): 简化 action_message 的数据类型处理"
This reverts commit 540b162c04.
2025-10-12 14:20:07 +08:00
minecraft1024a
540b162c04 refactor(chatter): 简化 action_message 的数据类型处理
在 `ActionPlannerInfo` 中,将 `action_message` 的类型直接设为 `target_message_obj` (dict),移除了之前将其转换为 `DatabaseMessages` 对象的逻辑。

这一改动简化了代码,并与最近 `reply_message` 模型重构的目的一致,即在流程中优先使用更通用的字典类型,仅在需要时进行模型转换。
2025-10-12 14:19:26 +08:00
minecraft1024a
9fdae38b6a refactor(replyer): 迁移 reply_messageDatabaseMessages 数据模型
将 `default_generator` 中使用的 `reply_message` 参数及其相关逻辑从旧的 SQLAlchemy `Messages` 模型迁移到新的 Pydantic `DatabaseMessages` 数据模型。

此更改统一了内部数据处理模型,提高了类型安全性和代码清晰度。同时,更新了所有对 `reply_message` 属性的访问方式,以适应新的嵌套数据结构(例如 `chat_info.platform` 和 `user_info.user_id`)。
2025-10-12 14:10:27 +08:00
minecraft1024a
e851dfbc62 refactor(replyer): 将 reply_message 类型从 dict 更改为 Messages 模型
将 `DefaultReplyer` 中多个方法的 `reply_message` 参数类型从通用的 `dict` 更改为更具体的 SQLAlchemy 模型 `Messages`。

这一更改提高了代码的类型安全性和可读性,使得数据结构更加明确。同时,更新了相关代码以直接访问模型属性,而不是使用字典的 `get()` 方法。
2025-10-12 14:03:20 +08:00
minecraft1024a
4df61eba1c fix(chatter): 修复私聊场景下目标信息类型不匹配问题
在 affinity_flow_chatter 插件中,处理私聊上下文时,`plan.target_info` 可能是一个字典(dict)类型,而不是预期的对象类型。这会导致在访问 `plan.target_info.person_name` 等属性时引发 `AttributeError`。

本次提交通过增加类型检查来处理这种情况,确保无论是对象还是字典类型的 `target_info` 都能被正确解析,从而增强了代码的健壮性并修复了潜在的运行时错误。
2025-10-12 13:48:05 +08:00