[**🇨🇳中文**](https://github.com/shibing624/ChatPilot/blob/main/README.md) | [**🌐English**](https://github.com/shibing624/ChatPilot/blob/main/README_EN.md)
<div align="center">
<a href="https://github.com/shibing624/ChatPilot">
<img src="https://github.com/shibing624/ChatPilot/blob/main/docs/favicon.png" height="150" alt="Logo">
</a>
</div>
-----------------
# ChatPilot: Chat Agent Web UI
[](https://badge.fury.io/py/ChatPilot)
[](https://pepy.tech/project/ChatPilot)
[](CONTRIBUTING.md)
[](LICENSE)
[](requirements.txt)
[](https://github.com/shibing624/ChatPilot/issues)
[](#Contact)
**ChatPilot**: Chat Agent WebUI, 实现了AgentChat对话,支持Google搜索、文件网址对话(RAG)、代码解释器功能,复现Kimi Chat(文件,拖进来;网址,发出来),支持OpenAI/Azure API。
## Features
- 本项目基于[Agentica](https://github.com/shibing624/agentica)实现了Agent Assistant调用,支持如下功能:
- 工具调用:支持Agent调用外部工具
- 联网搜索工具:Google Search API(Serper/DuckDuckGo)
- URL自动解析工具:复现了Kimi Chat网址发出来功能
- Python代码解释器:支持E2B虚拟环境和本地python编译器环境运行代码
- 多种LLM接入:支持多种LLM模型以多方式接入,包括使用Ollama Api接入各种本地开源模型;使用litellm Api接入各云服务部署模型;使用OpenAI Api接入GPT系列模型
- RAG:支持Agent调用RAG文件问答
- 支持前后端服务分离,前端使用Svelte,后端使用FastAPI
- 支持语音输入输出,支持图像生成
- 支持用户管理,权限控制,支持聊天记录导入导出
## Demo
Official Demo: https://chat.mulanai.com

## Getting Started
### Run ChatPilot in Docker
```shell
export OPENAI_API_KEY=sk-xxx
export OPENAI_BASE_URL=https://xxx/v1
docker run -it \
-e OPENAI_API_KEY=$WORKSPACE_BASE \
-e OPENAI_BASE_URL=$OPENAI_BASE_URL \
-e RAG_EMBEDDING_MODEL="text-embedding-ada-002" \
-p 8080:8080 --name chatpilot-$(date +%Y%m%d%H%M%S) shibing624/chatpilot:0.0.1
```
You'll find ChatPilot running at http://0.0.0.0:8080 Enjoy! 😄
### 本地启动服务
```shell
git clone https://github.com/shibing624/ChatPilot.git
cd ChatPilot
pip install -r requirements.txt
# Copying required .env file, and fill in the LLM api key
cp .env.example .env
bash start.sh
```
好了,现在你的应用正在运行:http://0.0.0.0:8080 Enjoy! 😄
### 构建前端web
两种方法构建前端:
1. 下载打包并编译好的前端 [buid.zip](https://github.com/shibing624/ChatPilot/releases/download/0.1.2/build.zip) 解压到项目web目录下。
2. 如果修改了web前端代码,需要自己使用npm重新构建前端:
```sh
git clone https://github.com/shibing624/ChatPilot.git
cd ChatPilot/
# Building Frontend Using Node.js >= 20.10
cd web
npm install
npm run build
```
输出:项目`web`目录产出`build`文件夹,包含了前端编译输出文件。
### 多种LLM接入
#### 使用OpenAI Api接入GPT系列模型
- 使用OpenAI API,配置环境变量:
```shell
export OPENAI_API_KEY=xxx
export OPENAI_BASE_URL=https://api.openai.com/v1
export MODEL_TYPE="openai"
```
- 如果使用Azure OpenAI API,需要配置如下环境变量:
```shell
export AZURE_OPENAI_API_KEY=
export AZURE_OPENAI_API_VERSION=
export AZURE_OPENAI_ENDPOINT=
export MODEL_TYPE="azure"
```
#### 使用Ollama Api接入各种本地开源模型
以`ollama serve`启动ollama服务,然后配置`OLLAMA_API_URL`:`export OLLAMA_API_URL=http://localhost:11413`
#### 使用litellm Api接入各云服务部署模型
1. 安装`litellm`包:
```shell
pip install litellm -U
```
2. 修改配置文件
`chatpilot`默认的litellm config文件在`~/.cache/chatpilot/data/litellm/config.yaml`
修改其内容如下:
```yaml
model_list:
# - model_name: moonshot-v1-auto # show model name in the UI
# litellm_params: # all params accepted by litellm.completion() - https://docs.litellm.ai/docs/completion/input
# model: openai/moonshot-v1-auto # MODEL NAME sent to `litellm.completion()` #
# api_base: https://api.moonshot.cn/v1
# api_key: sk-xx
# rpm: 500 # [OPTIONAL] Rate limit for this deployment: in requests per minute (rpm)
- model_name: deepseek-ai/DeepSeek-Coder # show model name in the UI
litellm_params: # all params accepted by litellm.completion() - https://docs.litellm.ai/docs/completion/input
model: openai/deepseek-coder # MODEL NAME sent to `litellm.completion()` #
api_base: https://api.deepseek.com/v1
api_key: sk-xx
rpm: 500
- model_name: openai/o1-mini # show model name in the UI
litellm_params: # all params accepted by litellm.completion() - https://docs.litellm.ai/docs/completion/input
model: o1-mini # MODEL NAME sent to `litellm.completion()` #
api_base: https://api.61798.cn/v1
api_key: sk-xxx
rpm: 500
litellm_settings: # module level litellm settings - https://github.com/BerriAI/litellm/blob/main/litellm/__init__.py
drop_params: True
set_verbose: False
```
## Contact
- Issue(建议):[](https://github.com/shibing624/ChatPilot/issues)
- 邮件我:xuming: xuming624@qq.com
- 微信我:加我*微信号:xuming624, 备注:姓名-公司-NLP* 进NLP交流群。
<img src="docs/wechat.jpeg" width="200" />
## Citation
如果你在研究中使用了ChatPilot,请按如下格式引用:
APA:
```latex
Xu, M. ChatPilot: LLM agent toolkit (Version 0.0.2) [Computer software]. https://github.com/shibing624/ChatPilot
```
BibTeX:
```latex
@misc{ChatPilot,
author = {Ming Xu},
title = {ChatPilot: llm agent},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/shibing624/ChatPilot}},
}
```
## License
授权协议为 [The Apache License 2.0](LICENSE),可免费用做商业用途。请在产品说明中附加ChatPilot的链接和授权协议。
## Contribute
项目代码还很粗糙,如果大家对代码有所改进,欢迎提交回本项目,在提交之前,注意以下两点:
- 在`tests`添加相应的单元测试
- 使用`python -m pytest -v`来运行所有单元测试,确保所有单测都是通过的
之后即可提交PR。
## Reference
- [Open WebUI](https://github.com/shibing624/ChatPilot)
- [langchain-ai/langchain](https://github.com/langchain-ai/langchain)
- [shibing624/agentica](https://github.com/shibing624/agentica)
Raw data
{
"_id": null,
"home_page": "https://github.com/shibing624/chatpilot",
"name": "chatpilot",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9.0",
"maintainer_email": null,
"keywords": "llm, agent",
"author": "XuMing",
"author_email": "xuming624@qq.com",
"download_url": "https://files.pythonhosted.org/packages/76/79/7374e48689a9f493b0453f0fdbfb2da37844aab9861b9c884c8778d4fcbd/chatpilot-1.0.1.tar.gz",
"platform": null,
"description": "[**\ud83c\udde8\ud83c\uddf3\u4e2d\u6587**](https://github.com/shibing624/ChatPilot/blob/main/README.md) | [**\ud83c\udf10English**](https://github.com/shibing624/ChatPilot/blob/main/README_EN.md) \n\n<div align=\"center\">\n <a href=\"https://github.com/shibing624/ChatPilot\">\n <img src=\"https://github.com/shibing624/ChatPilot/blob/main/docs/favicon.png\" height=\"150\" alt=\"Logo\">\n </a>\n</div>\n\n-----------------\n\n# ChatPilot: Chat Agent Web UI\n[](https://badge.fury.io/py/ChatPilot)\n[](https://pepy.tech/project/ChatPilot)\n[](CONTRIBUTING.md)\n[](LICENSE)\n[](requirements.txt)\n[](https://github.com/shibing624/ChatPilot/issues)\n[](#Contact)\n\n\n**ChatPilot**: Chat Agent WebUI, \u5b9e\u73b0\u4e86AgentChat\u5bf9\u8bdd\uff0c\u652f\u6301Google\u641c\u7d22\u3001\u6587\u4ef6\u7f51\u5740\u5bf9\u8bdd\uff08RAG\uff09\u3001\u4ee3\u7801\u89e3\u91ca\u5668\u529f\u80fd\uff0c\u590d\u73b0Kimi Chat(\u6587\u4ef6\uff0c\u62d6\u8fdb\u6765\uff1b\u7f51\u5740\uff0c\u53d1\u51fa\u6765)\uff0c\u652f\u6301OpenAI/Azure API\u3002\n\n\n## Features\n\n- \u672c\u9879\u76ee\u57fa\u4e8e[Agentica](https://github.com/shibing624/agentica)\u5b9e\u73b0\u4e86Agent Assistant\u8c03\u7528\uff0c\u652f\u6301\u5982\u4e0b\u529f\u80fd\uff1a\n - \u5de5\u5177\u8c03\u7528\uff1a\u652f\u6301Agent\u8c03\u7528\u5916\u90e8\u5de5\u5177\n - \u8054\u7f51\u641c\u7d22\u5de5\u5177\uff1aGoogle Search API\uff08Serper/DuckDuckGo\uff09\n - URL\u81ea\u52a8\u89e3\u6790\u5de5\u5177\uff1a\u590d\u73b0\u4e86Kimi Chat\u7f51\u5740\u53d1\u51fa\u6765\u529f\u80fd\n - Python\u4ee3\u7801\u89e3\u91ca\u5668\uff1a\u652f\u6301E2B\u865a\u62df\u73af\u5883\u548c\u672c\u5730python\u7f16\u8bd1\u5668\u73af\u5883\u8fd0\u884c\u4ee3\u7801\n - \u591a\u79cdLLM\u63a5\u5165\uff1a\u652f\u6301\u591a\u79cdLLM\u6a21\u578b\u4ee5\u591a\u65b9\u5f0f\u63a5\u5165\uff0c\u5305\u62ec\u4f7f\u7528Ollama Api\u63a5\u5165\u5404\u79cd\u672c\u5730\u5f00\u6e90\u6a21\u578b\uff1b\u4f7f\u7528litellm Api\u63a5\u5165\u5404\u4e91\u670d\u52a1\u90e8\u7f72\u6a21\u578b\uff1b\u4f7f\u7528OpenAI Api\u63a5\u5165GPT\u7cfb\u5217\u6a21\u578b\n - RAG\uff1a\u652f\u6301Agent\u8c03\u7528RAG\u6587\u4ef6\u95ee\u7b54\n- \u652f\u6301\u524d\u540e\u7aef\u670d\u52a1\u5206\u79bb\uff0c\u524d\u7aef\u4f7f\u7528Svelte\uff0c\u540e\u7aef\u4f7f\u7528FastAPI\n- \u652f\u6301\u8bed\u97f3\u8f93\u5165\u8f93\u51fa\uff0c\u652f\u6301\u56fe\u50cf\u751f\u6210\n- \u652f\u6301\u7528\u6237\u7ba1\u7406\uff0c\u6743\u9650\u63a7\u5236\uff0c\u652f\u6301\u804a\u5929\u8bb0\u5f55\u5bfc\u5165\u5bfc\u51fa\n\n## Demo\n\nOfficial Demo: https://chat.mulanai.com\n\n\n\n## Getting Started\n\n### Run ChatPilot in Docker\n\n```shell\nexport OPENAI_API_KEY=sk-xxx\nexport OPENAI_BASE_URL=https://xxx/v1\n\ndocker run -it \\\n -e OPENAI_API_KEY=$WORKSPACE_BASE \\\n -e OPENAI_BASE_URL=$OPENAI_BASE_URL \\\n -e RAG_EMBEDDING_MODEL=\"text-embedding-ada-002\" \\\n -p 8080:8080 --name chatpilot-$(date +%Y%m%d%H%M%S) shibing624/chatpilot:0.0.1\n```\nYou'll find ChatPilot running at http://0.0.0.0:8080 Enjoy! \ud83d\ude04\n\n### \u672c\u5730\u542f\u52a8\u670d\u52a1\n\n```shell\ngit clone https://github.com/shibing624/ChatPilot.git\ncd ChatPilot\npip install -r requirements.txt\n\n# Copying required .env file, and fill in the LLM api key\ncp .env.example .env\n\nbash start.sh\n```\n\u597d\u4e86\uff0c\u73b0\u5728\u4f60\u7684\u5e94\u7528\u6b63\u5728\u8fd0\u884c\uff1ahttp://0.0.0.0:8080 Enjoy! \ud83d\ude04\n\n\n### \u6784\u5efa\u524d\u7aefweb\n\n\u4e24\u79cd\u65b9\u6cd5\u6784\u5efa\u524d\u7aef\uff1a\n1. \u4e0b\u8f7d\u6253\u5305\u5e76\u7f16\u8bd1\u597d\u7684\u524d\u7aef [buid.zip](https://github.com/shibing624/ChatPilot/releases/download/0.1.2/build.zip) \u89e3\u538b\u5230\u9879\u76eeweb\u76ee\u5f55\u4e0b\u3002\n2. \u5982\u679c\u4fee\u6539\u4e86web\u524d\u7aef\u4ee3\u7801\uff0c\u9700\u8981\u81ea\u5df1\u4f7f\u7528npm\u91cd\u65b0\u6784\u5efa\u524d\u7aef\uff1a\n ```sh\n git clone https://github.com/shibing624/ChatPilot.git\n cd ChatPilot/\n \n # Building Frontend Using Node.js >= 20.10\n cd web\n npm install\n npm run build\n ```\n \u8f93\u51fa\uff1a\u9879\u76ee`web`\u76ee\u5f55\u4ea7\u51fa`build`\u6587\u4ef6\u5939\uff0c\u5305\u542b\u4e86\u524d\u7aef\u7f16\u8bd1\u8f93\u51fa\u6587\u4ef6\u3002\n\n### \u591a\u79cdLLM\u63a5\u5165\n#### \u4f7f\u7528OpenAI Api\u63a5\u5165GPT\u7cfb\u5217\u6a21\u578b\n- \u4f7f\u7528OpenAI API\uff0c\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1a\n```shell\nexport OPENAI_API_KEY=xxx\nexport OPENAI_BASE_URL=https://api.openai.com/v1\nexport MODEL_TYPE=\"openai\"\n```\n\n- \u5982\u679c\u4f7f\u7528Azure OpenAI API\uff0c\u9700\u8981\u914d\u7f6e\u5982\u4e0b\u73af\u5883\u53d8\u91cf\uff1a\n```shell\nexport AZURE_OPENAI_API_KEY=\nexport AZURE_OPENAI_API_VERSION=\nexport AZURE_OPENAI_ENDPOINT=\nexport MODEL_TYPE=\"azure\"\n```\n\n#### \u4f7f\u7528Ollama Api\u63a5\u5165\u5404\u79cd\u672c\u5730\u5f00\u6e90\u6a21\u578b\n\n\u4ee5`ollama serve`\u542f\u52a8ollama\u670d\u52a1\uff0c\u7136\u540e\u914d\u7f6e`OLLAMA_API_URL`\uff1a`export OLLAMA_API_URL=http://localhost:11413`\n\n#### \u4f7f\u7528litellm Api\u63a5\u5165\u5404\u4e91\u670d\u52a1\u90e8\u7f72\u6a21\u578b\n1. \u5b89\u88c5`litellm`\u5305\uff1a\n\n```shell\npip install litellm -U\n```\n\n2. \u4fee\u6539\u914d\u7f6e\u6587\u4ef6\n\n`chatpilot`\u9ed8\u8ba4\u7684litellm config\u6587\u4ef6\u5728`~/.cache/chatpilot/data/litellm/config.yaml`\n\n\u4fee\u6539\u5176\u5185\u5bb9\u5982\u4e0b\uff1a\n```yaml\nmodel_list:\n# - model_name: moonshot-v1-auto # show model name in the UI\n# litellm_params: # all params accepted by litellm.completion() - https://docs.litellm.ai/docs/completion/input\n# model: openai/moonshot-v1-auto # MODEL NAME sent to `litellm.completion()` #\n# api_base: https://api.moonshot.cn/v1\n# api_key: sk-xx\n# rpm: 500 # [OPTIONAL] Rate limit for this deployment: in requests per minute (rpm)\n\n - model_name: deepseek-ai/DeepSeek-Coder # show model name in the UI\n litellm_params: # all params accepted by litellm.completion() - https://docs.litellm.ai/docs/completion/input\n model: openai/deepseek-coder # MODEL NAME sent to `litellm.completion()` #\n api_base: https://api.deepseek.com/v1\n api_key: sk-xx\n rpm: 500\n - model_name: openai/o1-mini # show model name in the UI\n litellm_params: # all params accepted by litellm.completion() - https://docs.litellm.ai/docs/completion/input\n model: o1-mini # MODEL NAME sent to `litellm.completion()` #\n api_base: https://api.61798.cn/v1\n api_key: sk-xxx\n rpm: 500\nlitellm_settings: # module level litellm settings - https://github.com/BerriAI/litellm/blob/main/litellm/__init__.py\n drop_params: True\n set_verbose: False\n```\n\n## Contact\n\n- Issue(\u5efa\u8bae)\uff1a[](https://github.com/shibing624/ChatPilot/issues)\n- \u90ae\u4ef6\u6211\uff1axuming: xuming624@qq.com\n- \u5fae\u4fe1\u6211\uff1a\u52a0\u6211*\u5fae\u4fe1\u53f7\uff1axuming624, \u5907\u6ce8\uff1a\u59d3\u540d-\u516c\u53f8-NLP* \u8fdbNLP\u4ea4\u6d41\u7fa4\u3002\n\n<img src=\"docs/wechat.jpeg\" width=\"200\" />\n\n\n## Citation\n\n\u5982\u679c\u4f60\u5728\u7814\u7a76\u4e2d\u4f7f\u7528\u4e86ChatPilot\uff0c\u8bf7\u6309\u5982\u4e0b\u683c\u5f0f\u5f15\u7528\uff1a\n\nAPA:\n```latex\nXu, M. ChatPilot: LLM agent toolkit (Version 0.0.2) [Computer software]. https://github.com/shibing624/ChatPilot\n```\n\nBibTeX:\n```latex\n@misc{ChatPilot,\n author = {Ming Xu},\n title = {ChatPilot: llm agent},\n year = {2024},\n publisher = {GitHub},\n journal = {GitHub repository},\n howpublished = {\\url{https://github.com/shibing624/ChatPilot}},\n}\n```\n\n## License\n\n\n\u6388\u6743\u534f\u8bae\u4e3a [The Apache License 2.0](LICENSE)\uff0c\u53ef\u514d\u8d39\u7528\u505a\u5546\u4e1a\u7528\u9014\u3002\u8bf7\u5728\u4ea7\u54c1\u8bf4\u660e\u4e2d\u9644\u52a0ChatPilot\u7684\u94fe\u63a5\u548c\u6388\u6743\u534f\u8bae\u3002\n\n\n## Contribute\n\u9879\u76ee\u4ee3\u7801\u8fd8\u5f88\u7c97\u7cd9\uff0c\u5982\u679c\u5927\u5bb6\u5bf9\u4ee3\u7801\u6709\u6240\u6539\u8fdb\uff0c\u6b22\u8fce\u63d0\u4ea4\u56de\u672c\u9879\u76ee\uff0c\u5728\u63d0\u4ea4\u4e4b\u524d\uff0c\u6ce8\u610f\u4ee5\u4e0b\u4e24\u70b9\uff1a\n\n - \u5728`tests`\u6dfb\u52a0\u76f8\u5e94\u7684\u5355\u5143\u6d4b\u8bd5\n - \u4f7f\u7528`python -m pytest -v`\u6765\u8fd0\u884c\u6240\u6709\u5355\u5143\u6d4b\u8bd5\uff0c\u786e\u4fdd\u6240\u6709\u5355\u6d4b\u90fd\u662f\u901a\u8fc7\u7684\n\n\u4e4b\u540e\u5373\u53ef\u63d0\u4ea4PR\u3002\n\n## Reference\n\n- [Open WebUI](https://github.com/shibing624/ChatPilot)\n- [langchain-ai/langchain](https://github.com/langchain-ai/langchain)\n- [shibing624/agentica](https://github.com/shibing624/agentica)\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Chat Agent toolkit.",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/shibing624/chatpilot"
},
"split_keywords": [
"llm",
" agent"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "76797374e48689a9f493b0453f0fdbfb2da37844aab9861b9c884c8778d4fcbd",
"md5": "e07bfc4cb1de059edf9fd6aaf9c6d542",
"sha256": "d9ea2996ea53e43c6fa8ef31c6439e5f257ff9909abfdb8a8d53a13926156132"
},
"downloads": -1,
"filename": "chatpilot-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "e07bfc4cb1de059edf9fd6aaf9c6d542",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9.0",
"size": 42272,
"upload_time": "2024-12-25T14:17:50",
"upload_time_iso_8601": "2024-12-25T14:17:50.358368Z",
"url": "https://files.pythonhosted.org/packages/76/79/7374e48689a9f493b0453f0fdbfb2da37844aab9861b9c884c8778d4fcbd/chatpilot-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-25 14:17:50",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "shibing624",
"github_project": "chatpilot",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "jieba",
"specs": [
[
">=",
"0.39"
]
]
},
{
"name": "loguru",
"specs": []
},
{
"name": "tqdm",
"specs": []
},
{
"name": "pandas",
"specs": []
},
{
"name": "tiktoken",
"specs": []
},
{
"name": "openai",
"specs": []
},
{
"name": "text2vec",
"specs": []
},
{
"name": "chromadb",
"specs": []
},
{
"name": "agentica",
"specs": []
},
{
"name": "langchain",
"specs": []
},
{
"name": "langchain_community",
"specs": []
},
{
"name": "dashscope",
"specs": []
},
{
"name": "fastapi",
"specs": []
},
{
"name": "loguru",
"specs": []
},
{
"name": "uvicorn",
"specs": []
},
{
"name": "gunicorn",
"specs": []
},
{
"name": "python-multipart",
"specs": []
},
{
"name": "sse-starlette",
"specs": []
},
{
"name": "python-socketio",
"specs": []
},
{
"name": "python-jose",
"specs": []
},
{
"name": "passlib",
"specs": []
},
{
"name": "bcrypt",
"specs": []
},
{
"name": "uuid",
"specs": []
},
{
"name": "requests",
"specs": []
},
{
"name": "aiohttp",
"specs": []
},
{
"name": "peewee",
"specs": []
},
{
"name": "litellm",
"specs": []
},
{
"name": "argon2-cffi",
"specs": []
},
{
"name": "apscheduler",
"specs": []
},
{
"name": "fake_useragent",
"specs": []
},
{
"name": "pypdf",
"specs": []
},
{
"name": "docx2txt",
"specs": []
},
{
"name": "markdown",
"specs": []
},
{
"name": "pandas",
"specs": []
},
{
"name": "openpyxl",
"specs": []
},
{
"name": "PyJWT",
"specs": []
},
{
"name": "pyjwt",
"specs": []
}
],
"lcname": "chatpilot"
}