[**🇨🇳中文**](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
[![PyPI version](https://badge.fury.io/py/ChatPilot.svg)](https://badge.fury.io/py/ChatPilot)
[![Downloads](https://static.pepy.tech/badge/ChatPilot)](https://pepy.tech/project/ChatPilot)
[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)
[![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
[![python_version](https://img.shields.io/badge/Python-3.9%2B-green.svg)](requirements.txt)
[![GitHub issues](https://img.shields.io/github/issues/shibing624/ChatPilot.svg)](https://github.com/shibing624/ChatPilot/issues)
[![Wechat Group](https://img.shields.io/badge/wechat-group-green.svg?logo=wechat)](#Contact)
**ChatPilot**: 实现AgentChat对话,支持Google搜索、文件网址对话(RAG)、代码解释器功能,复现Kimi Chat(文件,拖进来;网址,发出来),支持OpenAI/Azure API。
## Features
- 本项目基于LangChain实现了ReAct和OpenAI Function Call的Agent问答对话,支持如下工具自动调用:
- 联网搜索工具:Google Search API(Serper/DuckDuckGo)
- URL自动解析工具:复现了Kimi Chat网址发出来功能
- Python代码解释器:支持E2B虚拟环境和本地python编译器环境运行代码
- 本项目基于LangChain实现了支持query改写的检索增强RAG文件问答
- 支持前后端服务分离,前端使用Svelte,后端使用FastAPI
- 支持语音输入输出,支持图像生成
- 支持用户管理,权限控制,支持聊天记录导入导出
## Demo
Official Demo: https://chat.mulanai.com
![](https://github.com/shibing624/ChatPilot/blob/main/docs/shot.png)
## Install
```shell
pip install -U chatpilot
```
or
```shell
git clone https://github.com/shibing624/ChatPilot.git
cd ChatPilot
pip install -e .
```
## Usage
### 本地部署
#### 1. 构建前端web
两种方法构建前端:
1. 下载打包并编译好的前端 [buid.zip](https://github.com/shibing624/ChatPilot/releases/download/v0.0.2/build.zip) 解压到项目web目录下。
2. 自己使用npm构建前端
Requirements:
- 🐰 [Node.js](https://nodejs.org/en) >= 20.10 or [Bun](https://bun.sh) >= 1.0.21
- 🐍 [Python](https://python.org) >= 3.10
```sh
git clone https://github.com/shibing624/ChatPilot.git
cd ChatPilot/
# Copying required .env file
cp .env.example .env
# Building Frontend Using Node
cd web
npm install
npm run build
```
输出:项目`web`目录产出`build`文件夹,包含了前端编译输出文件。
#### 2. 启动后端服务
```shell
cd ..
pip install -r requirements.txt -U
bash start.sh
```
好了,现在你的应用正在运行:http://0.0.0.0:8080 Enjoy! 😄
### 命令行模式(CLI)
支持命令行对话。
code: [cli.py](https://github.com/shibing624/ChatPilot/blob/main/chatpilot/cli.py)
```
> chatpilot -h
usage: __main__.py [-h] [--model MODEL] [--search SEARCH] [--openai_api_key OPENAI_API_KEY] [--openai_api_base OPENAI_API_BASE] [--serper_api_key SERPER_API_KEY]
chatpilot cli
options:
-h, --help show this help message and exit
--model MODEL openai model name
--search SEARCH search engine name, e.g. duckduckgo, serper
--openai_api_key OPENAI_API_KEY
openai api key
--openai_api_base OPENAI_API_BASE
openai api base url
--serper_api_key SERPER_API_KEY
serper api key
```
run:
```shell
pip install chatpilot -U
chatpilot
```
> User: 输入问题, 如:"一句话介绍北京"。
## Contact
- Issue(建议):[![GitHub issues](https://img.shields.io/github/issues/shibing624/ChatPilot.svg)](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)
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/95/40/1d96bd85452647cf610455103761be23301fcfe503138aa89c78cc5f9016/chatpilot-0.1.2.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\n[![PyPI version](https://badge.fury.io/py/ChatPilot.svg)](https://badge.fury.io/py/ChatPilot)\n[![Downloads](https://static.pepy.tech/badge/ChatPilot)](https://pepy.tech/project/ChatPilot)\n[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](CONTRIBUTING.md)\n[![License Apache 2.0](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)\n[![python_version](https://img.shields.io/badge/Python-3.9%2B-green.svg)](requirements.txt)\n[![GitHub issues](https://img.shields.io/github/issues/shibing624/ChatPilot.svg)](https://github.com/shibing624/ChatPilot/issues)\n[![Wechat Group](https://img.shields.io/badge/wechat-group-green.svg?logo=wechat)](#Contact)\n\n\n**ChatPilot**: \u5b9e\u73b0AgentChat\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\u4e8eLangChain\u5b9e\u73b0\u4e86ReAct\u548cOpenAI Function Call\u7684Agent\u95ee\u7b54\u5bf9\u8bdd\uff0c\u652f\u6301\u5982\u4e0b\u5de5\u5177\u81ea\u52a8\u8c03\u7528\uff1a\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- \u672c\u9879\u76ee\u57fa\u4e8eLangChain\u5b9e\u73b0\u4e86\u652f\u6301query\u6539\u5199\u7684\u68c0\u7d22\u589e\u5f3aRAG\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![](https://github.com/shibing624/ChatPilot/blob/main/docs/shot.png)\n\n## Install\n```shell\npip install -U chatpilot\n```\n\nor\n\n```shell\ngit clone https://github.com/shibing624/ChatPilot.git\ncd ChatPilot\npip install -e .\n```\n\n\n## Usage\n\n### \u672c\u5730\u90e8\u7f72\n\n#### 1. \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/v0.0.2/build.zip) \u89e3\u538b\u5230\u9879\u76eeweb\u76ee\u5f55\u4e0b\u3002\n2. \u81ea\u5df1\u4f7f\u7528npm\u6784\u5efa\u524d\u7aef\n\nRequirements:\n\n- \ud83d\udc30 [Node.js](https://nodejs.org/en) >= 20.10 or [Bun](https://bun.sh) >= 1.0.21\n- \ud83d\udc0d [Python](https://python.org) >= 3.10\n\n```sh\ngit clone https://github.com/shibing624/ChatPilot.git\ncd ChatPilot/\n\n# Copying required .env file\ncp .env.example .env\n\n# Building Frontend Using Node\ncd web\nnpm install\nnpm 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#### 2. \u542f\u52a8\u540e\u7aef\u670d\u52a1\n\n```shell\ncd ..\npip install -r requirements.txt -U\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### \u547d\u4ee4\u884c\u6a21\u5f0f\uff08CLI\uff09\n\n\u652f\u6301\u547d\u4ee4\u884c\u5bf9\u8bdd\u3002\n\ncode: [cli.py](https://github.com/shibing624/ChatPilot/blob/main/chatpilot/cli.py)\n\n```\n> chatpilot -h \nusage: __main__.py [-h] [--model MODEL] [--search SEARCH] [--openai_api_key OPENAI_API_KEY] [--openai_api_base OPENAI_API_BASE] [--serper_api_key SERPER_API_KEY]\n\n\n\nchatpilot cli\n\n\noptions:\n -h, --help show this help message and exit\n --model MODEL openai model name\n --search SEARCH search engine name, e.g. duckduckgo, serper\n --openai_api_key OPENAI_API_KEY\n openai api key\n --openai_api_base OPENAI_API_BASE\n openai api base url\n --serper_api_key SERPER_API_KEY\n serper api key\n```\n\nrun\uff1a\n\n```shell\npip install chatpilot -U\nchatpilot\n```\n\n> User: \u8f93\u5165\u95ee\u9898, \u5982\uff1a\"\u4e00\u53e5\u8bdd\u4ecb\u7ecd\u5317\u4eac\"\u3002\n\n## Contact\n\n- Issue(\u5efa\u8bae)\uff1a[![GitHub issues](https://img.shields.io/github/issues/shibing624/ChatPilot.svg)](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",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Chat Agent toolkit.",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/shibing624/chatpilot"
},
"split_keywords": [
"llm",
" agent"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "95401d96bd85452647cf610455103761be23301fcfe503138aa89c78cc5f9016",
"md5": "8607c57164fdf0ad9b08a62164b5ddc9",
"sha256": "ed479df255ff1959c15dc79b6bc27780880b7f6afe64fb383e10d846d41e4409"
},
"downloads": -1,
"filename": "chatpilot-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "8607c57164fdf0ad9b08a62164b5ddc9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9.0",
"size": 48168,
"upload_time": "2024-04-04T10:54:05",
"upload_time_iso_8601": "2024-04-04T10:54:05.541767Z",
"url": "https://files.pythonhosted.org/packages/95/40/1d96bd85452647cf610455103761be23301fcfe503138aa89c78cc5f9016/chatpilot-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-04 10:54:05",
"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": "langchain",
"specs": [
[
"~=",
"0.1.11"
]
]
},
{
"name": "langchain-community",
"specs": [
[
"~=",
"0.0.27"
]
]
},
{
"name": "langchain-openai",
"specs": [
[
"~=",
"0.0.8"
]
]
},
{
"name": "langchain-experimental",
"specs": [
[
"~=",
"0.0.53"
]
]
},
{
"name": "openai",
"specs": [
[
"~=",
"1.13.3"
]
]
},
{
"name": "fastapi",
"specs": []
},
{
"name": "loguru",
"specs": []
},
{
"name": "uvicorn",
"specs": []
},
{
"name": "pydantic",
"specs": []
},
{
"name": "python-multipart",
"specs": []
},
{
"name": "sse-starlette",
"specs": []
},
{
"name": "flask",
"specs": []
},
{
"name": "flask_cors",
"specs": []
},
{
"name": "python-socketio",
"specs": []
},
{
"name": "python-jose",
"specs": []
},
{
"name": "passlib",
"specs": []
},
{
"name": "uuid",
"specs": []
},
{
"name": "requests",
"specs": []
},
{
"name": "aiohttp",
"specs": []
},
{
"name": "peewee",
"specs": []
},
{
"name": "bcrypt",
"specs": []
},
{
"name": "litellm",
"specs": [
[
"==",
"1.30.7"
]
]
},
{
"name": "argon2-cffi",
"specs": []
},
{
"name": "apscheduler",
"specs": []
},
{
"name": "fake_useragent",
"specs": []
},
{
"name": "chromadb",
"specs": []
},
{
"name": "pypdf",
"specs": []
},
{
"name": "docx2txt",
"specs": []
},
{
"name": "unstructured",
"specs": []
},
{
"name": "markdown",
"specs": []
},
{
"name": "pypandoc",
"specs": []
},
{
"name": "pandas",
"specs": []
},
{
"name": "openpyxl",
"specs": []
},
{
"name": "pyxlsb",
"specs": []
},
{
"name": "xlrd",
"specs": []
},
{
"name": "PyJWT",
"specs": []
},
{
"name": "pyjwt",
"specs": []
},
{
"name": "black",
"specs": []
},
{
"name": "duckduckgo-search",
"specs": [
[
"~=",
"5.1.0"
]
]
},
{
"name": "pdf2image",
"specs": []
},
{
"name": "pillow_heif",
"specs": []
},
{
"name": "pytesseract",
"specs": []
},
{
"name": "pikepdf",
"specs": []
},
{
"name": "text2vec",
"specs": []
}
],
"lcname": "chatpilot"
}