sigoden/aichat
GitHub: sigoden/aichat
一体化 LLM 命令行工具,整合多模型提供商、Shell 助手、RAG 和 Agent 能力,为终端用户提供高效统一的 AI 交互体验。
Stars: 9691 | Forks: 667
# AIChat:一体化 LLM CLI 工具
[](https://github.com/sigoden/aichat/actions/workflows/ci.yaml)
[](https://crates.io/crates/aichat)
[](https://discord.gg/mr3ZZUB9hG)
AIChat 是一款一体化 LLM CLI 工具,具备 Shell 助手、CMD 与 REPL 模式、RAG、AI 工具与智能体等功能。
## 安装
### 包管理器
- **Rust 开发者:** `cargo install aichat`
- **Homebrew/Linuxbrew 用户:** `brew install aichat`
- **Pacman 用户**: `pacman -S aichat`
- **Windows Scoop 用户:** `scoop install aichat`
- **Android Termux 用户:** `pkg install aichat`
### 预编译二进制文件
从 [GitHub Releases](https://github.com/sigoden/aichat/releases) 下载 macOS、Linux 和 Windows 的预编译二进制文件,解压缩后,将 `aichat` 二进制文件添加到您的 `$PATH` 中。
## 功能特性
### 多提供商
通过统一的接口无缝集成 20 多个主流 LLM 提供商。支持的提供商包括 OpenAI、Claude、Gemini (Google AI Studio)、Ollama、Groq、Azure-OpenAI、VertexAI、Bedrock、Github Models、Mistral、Deepseek、AI21、XAI Grok、Cohere、Perplexity、Cloudflare、OpenRouter、Ernie、Qianwen、Moonshot、ZhipuAI、MiniMax、Deepinfra、VoyageAI,以及任何兼容 OpenAI 的 API 提供商。
### CMD 模式
利用 AIChat 的 CMD 模式探索强大的命令行功能。

### REPL 模式
体验交互式 Chat-REPL,具备 Tab 自动补全、多行输入支持、历史搜索、可配置按键绑定和自定义 REPL 提示符等功能。

### Shell 助手
提升您的命令行效率。用自然语言描述您的任务,让 AIChat 将其转化为精准的 shell 命令。AIChat 能智能适应您的操作系统和 shell 环境。

### 多形式输入
接受多种输入形式,如 stdin、本地文件和目录以及远程 URL,在数据处理方面提供灵活性。
| Input | CMD | REPL |
| ----------------- | ------------------------------------ | -------------------------------- |
| CMD | `aichat hello` | |
| STDIN | `cat data.txt \| aichat` | |
| Last Reply | | `.file %%` |
| Local files | `aichat -f image.png -f data.txt` | `.file image.png data.txt` |
| Local directories | `aichat -f dir/` | `.file dir/` |
| Remote URLs | `aichat -f https://example.com` | `.file https://example.com` |
| External commands | ```aichat -f '`git diff`'``` | ```.file `git diff` ``` |
| Combine Inputs | `aichat -f dir/ -f data.txt explain` | `.file dir/ data.txt -- explain` |
### 角色
自定义角色以调整 LLM 行为,提升交互效率并提高生产力。

### 会话
通过会话保持上下文感知的对话,确保交互的连续性。

### 宏
将一系列 REPL 命令组合成自定义宏,从而简化重复性任务。

### RAG
将外部文档集成到您的 LLM 对话中,以获得更准确且符合上下文的相关回复。

### 函数调用
函数调用通过将 LLM 连接到外部工具和数据源来增强其能力。这开启了无限可能,使 LLM 能够超越其核心能力并处理更广泛的任务。
我们创建了一个新的仓库 [https://github.com/sigoden/llm-functions](https://github.com/sigoden/llm-functions),以帮助您充分利用此功能。
#### AI 工具与 MCP
集成外部工具以自动化任务、检索信息并在您的工作流程中直接执行操作。

#### AI 智能体 (OpenAI GPTs 的 CLI 版本)
AI Agent = 指令 + 工具 + 文档。

### 本地服务器功能
AIChat 包含一个轻量级的内置 HTTP 服务器,便于部署。
```
$ aichat --serve
Chat Completions API: http://127.0.0.1:8000/v1/chat/completions
Embeddings API: http://127.0.0.1:8000/v1/embeddings
Rerank API: http://127.0.0.1:8000/v1/rerank
LLM Playground: http://127.0.0.1:8000/playground
LLM Arena: http://127.0.0.1:8000/arena?num=2
```
#### 代理 LLM API
LLM Arena 是一个 Web 平台,您可以在其中并排比较不同的 LLM。
使用 curl 测试:
```
curl -X POST -H "Content-Type: application/json" -d '{
"model":"claude:claude-3-5-sonnet-20240620",
"messages":[{"role":"user","content":"hello"}],
"stream":true
}' http://127.0.0.1:8000/v1/chat/completions
```
#### LLM Playground
一个 Web 应用程序,可直接从浏览器与支持的 LLM 进行交互。

#### LLM Arena
一个并排比较不同 LLM 的 Web 平台。

## 自定义主题
AIChat 支持自定义深色和浅色主题,可高亮显示回复文本和代码块。

## 文档
- [Chat-REPL 指南](https://github.com/sigoden/aichat/wiki/Chat-REPL-Guide)
- [命令行指南](https://github.com/sigoden/aichat/wiki/Command-Line-Guide)
- [角色指南](https://github.com/sigoden/aichat/wiki/Role-Guide)
- [宏指南](https://github.com/sigoden/aichat/wiki/Macro-Guide)
- [RAG 指南](https://github.com/sigoden/aichat/wiki/RAG-Guide)
- [环境变量](https://github.com/sigoden/aichat/wiki/Environment-Variables)
- [配置指南](https://github.com/sigoden/aichat/wiki/Configuration-Guide)
- [自定义主题](https://github.com/sigoden/aichat/wiki/Custom-Theme)
- [自定义 REPL 提示符](https://github.com/sigoden/aichat/wiki/Custom-REPL-Prompt)
- [常见问题](https://github.com/sigoden/aichat/wiki/FAQ)
## 许可证
Copyright (c) 2023-2025 aichat-developers.
AIChat 根据 MIT 许可证或 Apache 许可证 2.0 的条款提供,您可任选其一。
有关许可证的详细信息,请参阅 LICENSE-APACHE 和 LICENSE-MIT 文件。
标签:AI代理, AI风险缓解, Chatbot, Claude, CLI, CVE检测, DLL 劫持, Gemini, LLM, LLM评估, Ollama, OpenAI, Petitpotam, RAG, REPL, Rust, Shell助手, Unmanaged PE, WiFi技术, 人工智能, 内存规避, 可视化界面, 多模型支持, 大语言模型, 威胁情报, 开发者工具, 开源, 效率工具, 检索增强生成, 用户模式Hook绕过, 终端, 网络流量审计, 网络调试, 自动化, 通知系统