{"id":19756791,"url":"https://github.com/imiphp/imi-ai","last_synced_at":"2025-04-09T07:10:21.183Z","repository":{"id":195456770,"uuid":"648572896","full_name":"imiphp/imi-ai","owner":"imiphp","description":"imi-ai is a ChatGPT open source project based on PHP+Swoole+Vue, which can be deployed simply and quickly.（imi-ai 是一个基于 PHP+Swoole+Vue 的 ChatGPT 开源项目，可以简单快速部署。）","archived":false,"fork":false,"pushed_at":"2025-03-08T03:42:24.000Z","size":2478,"stargazers_count":81,"open_issues_count":1,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-02T05:07:38.100Z","etag":null,"topics":["chatgpt","openai","php","swoole","vue"],"latest_commit_sha":null,"homepage":"https://ai.imiphp.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imiphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-02T09:31:55.000Z","updated_at":"2025-03-19T13:36:31.000Z","dependencies_parsed_at":"2024-01-29T10:09:42.274Z","dependency_job_id":"8660ef12-e6c1-4afa-99c9-1072af76e734","html_url":"https://github.com/imiphp/imi-ai","commit_stats":{"total_commits":317,"total_committers":1,"mean_commits":317.0,"dds":0.0,"last_synced_commit":"3b4203e8c82c531c489b5baae4bcb0f47fb7b139"},"previous_names":["imiphp/imi-ai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imiphp%2Fimi-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imiphp","download_url":"https://codeload.github.com/imiphp/imi-ai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994122,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","openai","php","swoole","vue"],"created_at":"2024-11-12T03:16:55.356Z","updated_at":"2025-04-09T07:10:21.149Z","avatar_url":"https://github.com/imiphp.png","language":"PHP","readme":"# imi-ai\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.imiphp.com\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://cdn.jsdelivr.net/gh/imiphp/imi-ai@master/res/logo.png\" alt=\"imi\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n[![Server test](https://github.com/imiphp/imi-ai/actions/workflows/server.yml/badge.svg)](https://github.com/imiphp/imi-ai/actions/workflows/server.yml)\n[![Web test](https://github.com/imiphp/imi-ai/actions/workflows/web.yml/badge.svg)](https://github.com/imiphp/imi-ai/actions/workflows/web.yml)\n[![Php Version](https://img.shields.io/badge/php-%3E=8.1-brightgreen.svg)](https://secure.php.net/)\n[![Swoole Version](https://img.shields.io/badge/swoole-%3E=5.0.3-brightgreen.svg)](https://github.com/swoole/swoole-src)\n[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/imiphp/imi-ai/blob/master/LICENSE)\n\n## 介绍\n\nimi-ai 是一个 AI 大模型开源项目，支持对话和 RAG 知识库功能。\n\n项目架构合理，代码编写优雅，简单快速部署。前后端代码完全开源，不管是学习自用还是商用二开都很适合。\n\n项目采用 MIT 协议开源，你可以方便地进行二次开发，并且可以用于商业用途。\n\n## 演示\n\n演示地址：\u003chttps://ai.imiphp.com/\u003e\n\n![演示](https://cdn.jsdelivr.net/gh/imiphp/imi-ai@master/res/1.jpg)\n![演示](https://cdn.jsdelivr.net/gh/imiphp/imi-ai@master/res/2.jpg)\n![演示](https://cdn.jsdelivr.net/gh/imiphp/imi-ai@master/res/3.jpg)\n![演示](https://cdn.jsdelivr.net/gh/imiphp/imi-ai@master/res/4.jpg)\n\n## 技术栈\n\n后端基于 [imi](https://github.com/imiphp/imi) (PHP+Swoole)\n\n前端基于 [Chanzhaoyu/chatgpt-web](https://github.com/Chanzhaoyu/chatgpt-web) (TypeScript+Vue3+Vite3+NaiveUI)\n\n后台基于 [honghuangdc/soybean-admin](https://github.com/honghuangdc/soybean-admin) (TypeScript+Vue3+Vite3+NaiveUI)\n\n## 功能列表\n\n### 用户\n\n* [x] 用户邮箱注册和登录\n* [ ] 用户手机号注册和登录\n* [ ] 微信登录（PC/公众号/小程序）\n\n### 聊天 AI\n\n* [x] ChatGPT 聊天 AI（OpenAI）\n* [x] 支持设置提示语（Prompt）\n* [x] 支持模型参数调参\n* [x] 服务端多会话储存和上下文逻辑\n* [x] 渲染代码高亮\n* [x] 渲染 LaTeX 公式\n* [x] 保存消息到本地图片\n* [x] 提示词模型商店\n* [x] 支持限流\n\n### 模型训练（RAG 知识库）\n\n* [x] OpenAI 多文件（压缩）模型训练\n* [x] OpenAI 单文件模型训练\n* [x] 聊天 AI 回答问题（可用于问题解答和客服等场景）\n* [ ] 搜索引擎，可定位文件\n* [x] 支持解压文件（zip、rar、7z、xz、gz、bz、tar.*）\n* [x] 支持解析 txt 文件\n* [x] 支持解析 md 文件\n* [x] 支持解析 docx 文件\n* [x] 支持解析 pdf 文件\n* [ ] 消息队列异步处理训练任务\n* [x] 支持对话限流\n\n### AI 生图\n\n* [ ] OpenAI 图片生成\n* [ ] Midjourney 图片生成\n\n### 计费系统\n\n* [x] Tokens 计费系统（卡）\n* [x] 在线支付购买卡（接口层）\n* [ ] 微信支付\n* [ ] 支付宝支付\n* [x] 输入卡号激活\n\n### 支持的模型厂商\n\n* [x] [OpenAI](https://openai.com/)\n* [x] [Ollama](https://ollama.com/)\n* [x] [Swoole AI](https://ai.swoole.com/)\n* [x] [Google Gemini](https://aistudio.google.com/)\n* [x] [BigModel 智谱AI](https://www.bigmodel.cn/)\n\n\u003e 使用 Ollama 提供的类 OpenAI API，可以支持几乎所有开源模型私有化部署\n\n### 其它\n\n* [x] 设计文档\n* [x] 接口文档\n* [ ] Docker 支持\n* [ ] 视频讲解教程\n\n更多功能计划中……\n\n\u003e 项目正在持续迭代中，欢迎所有人来贡献代码\n\n## 安装\n\n### 服务端\n\n**目录：**`server`\n\n**环境要求：**\n\n* Linux / MacOS，可用内存至少 2G，推荐使用 4G 内存\n\n* PHP \u003e= 8.1（扩展：curl、gd、mbstring、pdo_mysql、redis、swoole）\n\n* Swoole \u003e= v5.0.3（必须启用 `--enable-openssl --enable-swoole-curl` 编译，模型训练需启用 [--enable-swoole-pgsql](https://wiki.swoole.com/#/environment?id=-enable-swoole-pgsql) 编译）\n\n\u003e 建议直接使用 swoole-cli，可在 [Swoole Release 下载](https://github.com/swoole/swoole-src/releases)。\n\n* MySQL \u003e= 8.0.17\n\n* Redis\n\n* PostgreSQL + [pgvector](https://github.com/pgvector/pgvector) （可选，使用模型训练必选，需为项目数据库启用扩展 `CREATE EXTENSION vector;`）\n\n* 7-Zip，可选，但使用模型训练必选，用于解压文件。[下载](https://7-zip.org/download.html) 并将 `7zz` / `7zzs` 解压到 `/usr/bin/7z` 或 `/usr/local/bin/7z` 目录\n\n* Pandoc，可选，安装后可支持 docx 文件模型训练。[下载](https://pandoc.org/installing.html)\n\n* poppler-utils，可选，安装后可支持 pdf 文件模型训练。\n\n**安装：**\n\n```shell\n# Debian/Ubuntu\napt install poppler-utils\n# CentOS\nyum install poppler-utils\n# Alpine\napk add poppler-utils\n```\n\n**安装依赖：**\n\n`composer update`\n\n**生成证书：**\n\njwt 签名需要，必须生成自己的证书！\n\n```shell\ncd server/resource/jwt\nopenssl genrsa -out pri_key.pem 2048\nopenssl rsa -in pri_key.pem -pubout -out pub_key.pem\nopenssl genrsa -out admin_pri_key.pem 2048\nopenssl rsa -in admin_pri_key.pem -pubout -out admin_pub_key.pem\n```\n\n**配置文件：**\n\n复制 **.env.tpl** 改名为 **.env** 文件。\n\n根据文件内注释修改对应的配置。\n\n**应用配置：**\n\n后台-系统管理-系统设置\n\n**导入 MySQL：**\n\n首先创建 `db_imi_ai` 数据库，如果使用其它名称，需要在 `.env` 中修改。\n\n执行生成表结构命令：\n\n```shell\nvendor/bin/imi-swoole generate/table\n```\n\n**导入 PostgreSQL：**\n\n首先创建 `db_imi_ai` 数据库，如果使用其它名称，需要在 `.env` 中修改。\n\n为 `db_imi_ai` 或你使用的数据库启用 `pgvector` 扩展：\n\n```sql\nCREATE EXTENSION vector;\n```\n\n导入 `pgsql.sql` 文件，创建表。\n\n\u003e 不使用模型训练功能，可以不配置 PostgreSQL。\n\n**运行服务：**\n\n```shell\nvendor/bin/imi-swoole swoole/start\n```\n\n**生产环境：**\n\n编辑 **.env** 文件。\n\n必须的设置：\n\n```env\n# 生产环境禁用热更新\n@app.beans.hotUpdate.status=0\n# 生产环境禁用调试\nAPP_DEBUG=false\n```\n\n其它设置根据自身需要进行配置。\n\n### 用户端H5\n\n**目录：**`web`\n\n**环境要求：**\n\n`node` 需要 `^16 || ^18 || ^19` 版本（`node \u003e= 14` 需要安装 [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)），使用 [nvm](https://github.com/nvm-sh/nvm) 可管理本地多个 `node` 版本\n\n```shell\nnode -v\n```\n\n**安装依赖：**\n\n```shell\nnpm install\n```\n\n\u003e 也可以使用 yarn、pnpm 等。\n\n**配置：**\n\n复制 **.env.tpl** 改名为 **.env** 文件。\n\n编辑 **.env** 文件。\n\n* `VITE_GLOB_API_URL`，服务端接口地址，如：`http://127.0.0.1:12333/`\n\n* `VITE_APP_API_BASE_URL` 前端调试访问地址，如：`http://127.0.0.1:3100/`\n\n**开发调试：**\n\n```shell\nnpm run dev\n```\n\n**生产环境：**\n\n#### 编译\n\n```shell\nnpm run build-only\n```\n\n\u003e `npm run build` 也可以，但会执行类型检查，不规范的代码编译不通过。\n\n#### 编译结果\n\n所有文件都在 `dist` 目录，内部文件放到站点根目录。\n\n### 管理后台\n\n后台默认账号密码都是 `admin`\n\n**目录：**`admin`\n\n**环境要求：**\n\n`node` 需要 `^16 || ^18 || ^19` 版本（`node \u003e= 14` 需要安装 [fetch polyfill](https://github.com/developit/unfetch#usage-as-a-polyfill)），使用 [nvm](https://github.com/nvm-sh/nvm) 可管理本地多个 `node` 版本\n\n```shell\nnode -v\n```\n\n**安装依赖：**\n\n```shell\nnpm install\n```\n\n\u003e 也可以使用 yarn、pnpm 等。\n\n**配置：**\n\n复制 **.env.tpl** 改名为 **.env** 文件。\n\n编辑 **.env** 文件。\n\n* `VITE_API_URL`，服务端接口地址，如：`http://127.0.0.1:12333`\n\n**开发调试：**\n\n```shell\nnpm run dev\n```\n\n**生产环境：**\n\n#### 编译\n\n```shell\nnpm run build\n```\n\n\u003e `npm run build` 也可以，但会执行类型检查，不规范的代码编译不通过。\n\n#### 编译结果\n\n所有文件都在 `dist` 目录，内部文件放到站点根目录。\n\n## 技术支持\n\n可提供以下服务：项目搭建部署、技术咨询、定制开发等\n\n**QQ群：** 17916227\n\n**微信群：**\n\n![微信](https://cdn.jsdelivr.net/gh/imiphp/imi-ai@master/res/wechat.png)\n\n\u003e 先加好友再拉群，不注明来意不通过验证，谢谢理解！\n\n## 赞助开发\n\nimi-ai 是基于 MIT 协议完全开源的项目，为了能够更好地可持续发展，特推出赞助权益。\n\n### 赞助等级\n\n| 等级 | 价格 | 说明 |\n| - | - | - |\n| 白嫖用户 | 0 | 完整项目代码，免费用于商业用途，Github/QQ群/微信群交流提问 |\n| 白银赞助 | ￥9.9 | 可获得设计文档，接口文档 |\n| 黄金赞助 | ￥499/年 | 一对一问题咨询 |\n| 铂金赞助 | ￥888/年 | 支持私有化部署模型，1次免费项目搭建部署，一对一问题咨询 |\n\n### 权益\n\n| 权益 | 白嫖用户 | 白银赞助 | 黄金赞助 | 铂金赞助 | 备注 |\n| - | - | - | - | - | - |\n| 完整项目代码 | ✔ | ✔ | ✔ | ✔ |  |\n| 免费用于商业用途 | ✔ | ✔ | ✔ | ✔ |  |\n| Github/QQ群/微信群交流提问 | ✔ | ✔ | ✔ | ✔ | 回复时长不确定 |\n| 设计文档 |  | ✔ | ✔ | ✔ | 在线浏览 |\n| 接口文档（后台+前台） |  | ✔ | ✔ | ✔ | 在线浏览/Swagger 格式导出/Markdown |\n| 一对一问题咨询 |  |  | ✔ | ✔ | 回复及时，隐私更好 |\n| 项目搭建部署（1次） |  |  |  | ✔ | imi-ai + Ollama 私有化部署模型。建议提供干净的服务器，可用内存至少1G。后续升级请自行操作，或另外付费。 |\n\n**支付：**\n\n![赞助](https://cdn.jsdelivr.net/gh/imiphp/imi-ai@master/res/pay.png)\n\n## 定制开发\n\n承接 imi-ai 相关的二次开发、AI 应用定制开发等业务，欢迎咨询。\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimiphp%2Fimi-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimiphp%2Fimi-ai/lists"}