Mochi — 本地运行的个人 AI 助手,基于 LangGraph 构建
Project description
Mochi Agent
███╗ ███╗ ██████╗ ██████╗ ██╗ ██╗██╗ █████╗ ██╗
████╗ ████║ ██╔═══██╗██╔═══██╗██║ ██║██║ ██╔══██╗██║
██╔████╔██║ ██║ ██║██║ ██║███████║██║ ███████║██║
██║╚██╔╝██║ ██║ ██║██║ ██║██╔══██║██║ ██╔══██║██║
██║ ╚═╝ ██║ ╚██████╔╝╚██████╔╝██║ ██║███████╗██║ ██║██║
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝
Mochi — 本地运行的个人 AI 助手,基于 LangGraph 构建,支持多模型、长期记忆、MCP 工具扩展和技能系统。
✨ 功能特性
- 多模型支持 — DeepSeek、DashScope(阿里云)、OpenAI,其他供应商可通过 OpenAI 兼容模式接入
- 长期记忆 — 跨会话的持久化记忆系统,支持标签和搜索
- MCP 集成 — 通过 Model Context Protocol 连接外部工具服务器
- 技能系统 — 基于 YAML frontmatter 的
.md技能文件,可扩展 - 交互式 REPL — 基于 Rich + prompt_toolkit 的终端交互界面,支持多行输入
- 内置工具 — 文件操作、Shell 命令、Web 搜索
🚀 快速安装
方式一:PyPI 包安装(推荐)
# 创建 conda 环境
conda create -n mochi python=3.12 -y
conda activate mochi
# 安装
pip install mochi-assistant
# 启动
mochi
方式二:源码运行
# 克隆仓库
git clone https://github.com/LiangshouX/Mochi.git
cd Mochi
# 创建 conda 环境
conda create -n mochi python=3.12 -y
conda activate mochi
# 安装 Poetry(如尚未安装)
pip install poetry
# 安装依赖
poetry install
# 启动
python -m mochi_assistant
⚙️ 配置
首次运行会在 ~/.mochi/config/config.json 自动生成默认配置模板:
{
"mochi": {
"provider": "openai",
"model": "deepseek-chat",
"temperature": 0.7,
"max_tokens": 4096,
"api_key": "sk-your-api-key-here",
"base_url": null
},
"security": {
"allowed_directories": ["~"],
"dangerous_commands": ["rm -rf", "del /f /s /q", "format", "mkfs"],
"confirm_dangerous": true
},
"mcp": {
"servers": {}
}
}
修改 mochi.api_key 和 mochi.provider / mochi.model 即可切换模型。
支持的 LLM 供应商
| 供应商 | provider 值 | base_url | 模型示例 |
|---|---|---|---|
| DeepSeek | deepseek |
https://api.deepseek.com |
deepseek-chat, deepseek-coder, deepseek-reasoner |
| DashScope(阿里云) | dashscope |
https://dashscope.aliyuncs.com/compatible-mode/v1 |
qwen-turbo, qwen-plus, qwen-max, qwen-long |
| OpenAI | openai |
(默认) | gpt-4o, gpt-4o-mini, gpt-4-turbo |
OpenAI 兼容模式:如需使用其他供应商(如 Anthropic、Google、Ollama 等),可将
provider设为openai,并配置对应的base_url和api_key,即可通过 OpenAI 兼容接口接入。
📖 REPL 命令
| 命令 | 说明 |
|---|---|
/new |
创建新会话 |
/sessions |
列出会话(上下选择切换) |
/save |
保存当前会话 |
/model |
交互式选择模型 |
/skills |
列出已安装的 SKILL |
/mcp |
显示 MCP Server 列表 |
/mcp-new |
添加新的 MCP Server |
/memories |
列出长期记忆 |
/forget KEY |
删除指定记忆 |
/config |
显示当前配置 |
/help |
显示帮助 |
/exit |
退出 |
📁 工作区结构
运行后自动创建 ~/.mochi/ 工作区:
~/.mochi/
├── config/
│ └── config.json # 主配置文件
├── memory/
│ ├── sessions/ # 会话历史
│ └── long_term/ # 长期记忆存储
├── skills/ # 技能文件 (.md)
└── logs/ # 运行日志
🏗️ 项目结构
mochi_assistant/
├── __main__.py # python -m mochi_assistant 入口
├── config.py # Pydantic 配置模型 + ConfigManager
├── logging_config.py # 日志配置
├── cli/
│ └── app.py # REPL 界面 (MochiREPL)
├── agent/
│ ├── core.py # LangGraph Agent 状态图
│ ├── llm.py # LLM 工厂(多供应商抽象)
│ └── prompts.py # 系统提示词
├── memory/
│ ├── session.py # 短期记忆(会话)
│ └── long_term.py # 长期记忆(持久化)
├── tools/
│ ├── __init__.py # ToolRegistry 工具注册表
│ ├── file_ops.py # 文件操作工具
│ ├── shell.py # Shell 命令工具
│ └── web_search.py # Web 搜索工具
├── mcp/
│ ├── client.py # MCP 客户端
│ ├── config.py # MCP 配置模型
│ └── auth.py # MCP 认证
├── skills/
│ ├── schema.py # Skill 数据模型
│ ├── loader.py # 技能文件加载器
│ └── executor.py # 技能执行器
└── storage/
├── json_store.py # JSON 持久化存储
└── workspace.py # 工作区管理
🔧 开发
# 安装开发依赖
poetry install --with dev
# 运行测试
pytest
# 构建 PyPI 包
python scripts/build.py
# 清理并重新构建
python scripts/build.py --clean
📄 License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mochi_assistant-0.1.0.tar.gz.
File metadata
- Download URL: mochi_assistant-0.1.0.tar.gz
- Upload date:
- Size: 35.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b34c6186c2e7003d24451b8df0605f23a5a18fe96be9bf7901ae4a5bbb8bd7b7
|
|
| MD5 |
b0affc8a360344f75e05a7f4b06f6f7a
|
|
| BLAKE2b-256 |
9aea114ca787cba5f579cc46b96c9ee62674a3fb201e28cafc5bd43e94e0515a
|
Provenance
The following attestation bundles were made for mochi_assistant-0.1.0.tar.gz:
Publisher:
release.yml on LiangshouX/Mochi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mochi_assistant-0.1.0.tar.gz -
Subject digest:
b34c6186c2e7003d24451b8df0605f23a5a18fe96be9bf7901ae4a5bbb8bd7b7 - Sigstore transparency entry: 2071652834
- Sigstore integration time:
-
Permalink:
LiangshouX/Mochi@c04d84a5e9ef751171f97f73e305b775818d8b4b -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/LiangshouX
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c04d84a5e9ef751171f97f73e305b775818d8b4b -
Trigger Event:
release
-
Statement type:
File details
Details for the file mochi_assistant-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mochi_assistant-0.1.0-py3-none-any.whl
- Upload date:
- Size: 48.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
480e0a8db16504af01319f751b8e4c6ff8fecd7d65d6bebb750fb25f7e934f54
|
|
| MD5 |
d0d1cf36b1f613e030b4d9fcda1fcb36
|
|
| BLAKE2b-256 |
1a277afe352dad6d93267cbb267d80d60ba6db0a696ddd5eb5502c352f959d89
|
Provenance
The following attestation bundles were made for mochi_assistant-0.1.0-py3-none-any.whl:
Publisher:
release.yml on LiangshouX/Mochi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mochi_assistant-0.1.0-py3-none-any.whl -
Subject digest:
480e0a8db16504af01319f751b8e4c6ff8fecd7d65d6bebb750fb25f7e934f54 - Sigstore transparency entry: 2071652844
- Sigstore integration time:
-
Permalink:
LiangshouX/Mochi@c04d84a5e9ef751171f97f73e305b775818d8b4b -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/LiangshouX
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c04d84a5e9ef751171f97f73e305b775818d8b4b -
Trigger Event:
release
-
Statement type: