骆驼聊天
一个类似Claude代码的TUI,用于通过兼容OpenAI的API与本地和网络LLM对话。内置Rust和ratatui。
llama-chat [gemma4:latest] [Spark] [5 tools]
────────────────────────────────────────────────────────────────────────────────────
you: What files are in the current directory?
Reasoning [-] ─
│ Let me check the current directory contents.
│ I'll use the list_files tool to see what's there.
└──────────
⚙ list_files {"path":"."} ✓ allowed
Cargo.toml src/ tests/ README.md
gemma4:latest: You have 4 entries in the current directory: Cargo.toml, src/,
tests/, and README.md.
you: Create a hello world at /tmp/hello.rs
⚙ write_file {"path":"/tmp/hello.rs","content":"fn main() ..."} ✓ allowed
Wrote 42 bytes to /tmp/hello.rs
gemma4:latest: Done — wrote a hello world program to /tmp/hello.rs.
────────────────────────────────────────────────────────────────────────────────────
▸ Type a message... /help · /model · /server特性
- 多服务器 --配置多个Ollama/llama.cpp后端,切换
/server - 流媒体 --逐令牌响应呈现,实时shell逐行输出
- 工具调用 --带有权限提示的shell、read_file、write_file、edit_file、list_file
- MCP支持 --具有自动检测功能的stdio、SSE和流式HTTP传输
- 思维方式 --解析 `` 带有精美印刷、可折叠方块和独特视觉风格的标签
- 权限 --shell允许/拒绝/始终保存/模式提示;每个会话自动允许文件系统工具;
--yolo跳过所有提示 - 技能 --带有frontmatter的全局markdown文件(
~/.config/llama-chat/skills/)每个项目(.llama-chat/skills/) - 项目背景 --加载CLAUDE.md、AGENTS.md、游标
.cursor/rules/*.mdc,以及.llama-chat/context.md根据系统提示 - 主题 --带有每种颜色十六进制覆盖的暗/亮预设,包括特定思考的颜色
- 记忆 --具有自动对话存档、混合FTS+矢量搜索和基于LLM的提取的长期记忆
记忆
llama聊天包括一个可选的长期记忆系统,该系统维护两个数据库:
- 全球 (
~/.local/share/llama-chat/global.db)--用户偏好、反馈、跨项目事实 - 项目 (
.llama-chat/memory.db)--项目特定背景、对话档案
配置
# config.toml
[memory]
enabled = true
embedding_model = "nomic-embed-text" # model name for embeddings
embedding_server = "local" # server from [servers] to use
top_n = 8 # max memories injected per turn
decay_half_life_days = 90 # time decay for curated memories
extraction_on_clear = true # run extraction on /clear
[servers.local]
url = "http://localhost:11434/v1"嵌入服务器必须支持OpenAI兼容 /embeddings 终点。所有主要的本地LLM服务器(Ollama、llama.cpp、vLLM)都支持此功能。
Slash命令
| 命令 | 操作 |
|---|---|
/remember | 保存精心策划的记忆(用户偏好、项目事实等) |
/forget | 按ID删除内存 |
/memory [limit] | 列出最近的回忆 |
运作原理
- 自动归档:每个对话回合都被分块(500个令牌,50个令牌重叠),嵌入并存储在项目数据库中
- 混合检索:用户消息触发全文搜索(FTS5)和向量搜索(HNSW),并与互惠排名融合
- 注入:Top-N内存作为 `` 块
- 会话提取结束:打开
/clear或/exit,法学硕士审查对话并提取关键事实,以保存为精心策划的记忆 - 孤儿康复:崩溃的会话将在下次启动时自动提取
记忆是有作用域的:全局记忆出现在所有项目中,项目记忆只出现在他们的项目中。
安装
cargo install --path .需要Rust 1.85+(2024版)。
配置
Config住在 ~/.config/llama-chat/:
# config.toml
[servers.local]
name = "Local Ollama"
url = "http://localhost:11434/v1"
[servers.remote]
name = "GPU Box"
url = "http://gpu-box:8080/v1"
api_key = "sk-your-token-here"
[defaults]
server = "local"
model = "llama3:8b"
show_thinking = true # show/hide thinking blocks (default: true)
[theme]
preset = "dark" # or "light"
[theme.colors] # optional overrides
accent = "#818cf8"
tool_ok = "#34d399"
thinking_header = "#fbbf24" # thinking block header color
thinking_text = "#b4b4b4" # thinking block text color
thinking_border = "#fbbf24" # thinking block border colorMCP服务器
// ~/.config/llama-chat/mcp.json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user"]
},
"remote": {
"url": "http://mcp-server:3001/sse"
}
}
}自动检测传输: command 字段表示stdio, url 字段尝试流式HTTP,然后回退到SSE。集 "transport": "sse" 以覆盖。
用法
llama-chat # normal mode
llama-chat --yolo # skip all permission promptsSlash命令
| 命令 | 操作 |
|---|---|
/model [name] | 可用的开关型号或列表 |
/server [name] | 已配置交换机服务器或列表 |
/tools | 列出活动工具 |
/skills | 列出技能 |
/thinking | 切换思维显示 |
/init | 为项目生成AGENTS.md |
/remember | 保存内存(如果启用了内存) |
/forget | 按ID删除内存 |
/memory [limit] | 列出最近的回忆 |
/clear | 清除对话(如果启用,则运行提取) |
/help | 显示命令 |
/exit | 退出(如果启用,则运行提取) |
技能按名称调用: /review, /explain等等。
快捷键
| 关键 | 行动 |
|---|---|
Enter | 发送消息 |
Ctrl+C | 停止生成(流式传输时)/退出(空闲时) |
t | 切换思维显示 |
Esc | 退出 |
A | 允许工具调用 |
D | 拒绝工具调用 |
S | 始终保存(保存到permissions.json) |
P | 保存球形图案 |
按项目配置
.llama-chat/
├── permissions.json # saved allow rules
├── context.md # project-specific system prompt
└── skills/ # project-specific skills该应用程序还读取 CLAUDE.md, AGENTS.md,以及 .cursor/rules/*.mdc 从项目根开始,与其他AI工具兼容。
建筑
带有tokio的事件驱动异步应用程序。三个输入源为中央mpsc通道供电:
Terminal input (crossterm) ──┐
API stream (reqwest SSE) ──┼──▸ Event Channel ──▸ App State Machine ──▸ ratatui render
MCP clients (stdio/http) ──┘许可证
麻省理工学院
