|
23 | 23 | ├── pyproject.toml # 后端依赖 配置文件 |
24 | 24 | └── ui # 前端项目根目录 |
25 | 25 | ├── config_example.yml # 项目配置示例 |
26 | | - ├── main.py # 项目入口文件 python main.py start 启动项目 |
| 26 | + ├── main.py # 项目入口文件 |
27 | 27 | ``` |
28 | 28 |
|
29 | 29 | ## 2 环境准备 |
30 | 30 |
|
31 | 31 | !!! Abstract "" |
32 | 32 | - **前端环境准备** |
33 | | - 安装 [node](https://nodejs.org/) |
| 33 | + 安装 [node](https://nodejs.org/) ,v16及以上版本 |
34 | 34 | - **后端环境准备** |
35 | | - 安装 [python](https://www.python.org/downloads/release/python-3115/) |
| 35 | + 安装 [python](https://www.python.org/downloads/release/python-3115/) ,版本 v3.11.x |
36 | 36 | 安装 [pycharm](https://www.jetbrains.com/pycharm/download/) |
| 37 | + - **数据库** |
| 38 | + 安装 [PostgreSql](https://www.postgresql.org/) ,版本 v15.x |
37 | 39 |
|
38 | | -## 3 开发环境搭建 |
| 40 | +## 3 本地配置 |
| 41 | + |
| 42 | +### 3.1 创建数据库 |
39 | 43 |
|
40 | 44 | !!! Abstract "" |
41 | | - 安装 poetry 包管理器 |
42 | | - ``` bash |
43 | | - pip install poetry |
| 45 | + 在 PostgreSql 中手动创建MaxKB 应用数据库,名称为`maxkb`。 |
| 46 | + ``` |
| 47 | + # 创建数据库 |
| 48 | + CREATE DATABASE "maxkb"; |
| 49 | + # 切换使用数据库 |
| 50 | + \c "maxkb"; |
| 51 | + # 创建vector 扩展 |
| 52 | + CREATE EXTENSION "vector"; |
44 | 53 | ``` |
45 | 54 |
|
46 | | -## 4 本地配置 |
| 55 | +### 3.2 配置文件 |
47 | 56 |
|
48 | 57 | !!! Abstract "" |
49 | 58 | 项目启动之前,需要准备配置文件及目录 |
50 | 59 |
|
51 | 60 | - 准备配置文件 |
52 | 61 |
|
53 | 62 | ```bash |
54 | | - # 将config_example.yml配置文件 目录拷贝至 /opt/maxkb/conf目录下 如果是Windows D:\\opt\\maxkb\\conf |
| 63 | + # 将config_example.yml配置文件拷贝至 /opt/maxkb/conf目录下 |
55 | 64 | cp config_example.yml /opt/maxkb/conf |
56 | 65 | ``` |
57 | 66 |
|
58 | 67 | - 配置 /opt/maxkb/conf/config_example.yml |
59 | 68 |
|
60 | 69 | ``` |
61 | | - # 数据库配置 |
| 70 | + # 数据库配置(将以下信息替换为实际环境信息) |
62 | 71 | DB_NAME: maxkb |
63 | 72 | DB_HOST: localhost |
64 | 73 | DB_PORT: 5432 |
|
73 | 82 | EMBEDDING_MODEL_NAME: /opt/maxkb/model/shibing624_text2vec-base-chinese |
74 | 83 | ``` |
75 | 84 |
|
76 | | -## 5 开发调试 |
| 85 | +## 4 开发调试 |
77 | 86 |
|
78 | | -### 5.1 启动前端项目 |
| 87 | +### 4.1 启动前端 |
79 | 88 |
|
80 | 89 | !!! Abstract "" |
81 | | - 先在ui执行安装前端需要的依赖 |
82 | 90 |
|
83 | | - ```bash |
84 | | - npm install |
85 | | - ``` |
| 91 | + ```bash |
| 92 | + # 在 `ui`目录 执行安装前端需要的依赖 |
| 93 | + npm install |
| 94 | + |
| 95 | + # 然后启动项目 |
| 96 | + npm run dev |
| 97 | + ``` |
86 | 98 |
|
87 | | - 启动项目 |
88 | | - ```bash |
89 | | - npm run dev |
90 | | - ``` |
| 99 | + 启动成功后,如下图显示。 |
91 | 100 |
|
92 | | -### 5.2 启动后端项目 |
| 101 | +{width="500px"} |
| 102 | + |
| 103 | + |
| 104 | +### 4.2 启动后端 |
93 | 105 |
|
94 | 106 | !!! Abstract "" |
95 | | - 注意: 在项目根目录执行 |
| 107 | + 后端系统,需要启动 web服务、本地模型服务、和异步任务队列服务。 |
| 108 | + 注意: 在项目根目录执行 |
96 | 109 |
|
97 | | - 创建venv |
98 | | - ``` |
99 | | - # win |
100 | | - python -m venv venv |
| 110 | +!!! Abstract "" |
| 111 | + 在 MaxKB 项目根目录下依次执行以下命令,启动 Web 服务。 |
101 | 112 |
|
102 | | - # linux/mac |
103 | | - python3 -m venv venv |
104 | | - ``` |
| 113 | + ``` |
| 114 | + # 安装 poetry 包管理器 |
| 115 | + pip install poetry |
| 116 | + |
| 117 | + # 安装后端需要的依赖 |
| 118 | + poetry install |
| 119 | + |
| 120 | + # 启动项目 |
| 121 | + python main.py start |
| 122 | + ``` |
105 | 123 |
|
106 | | - 激活 venv |
107 | | - ``` |
108 | | - # win |
109 | | - .\venv\Scripts\activate |
| 124 | +{width="500px"} |
110 | 125 |
|
111 | | - # linux/mac |
112 | | - source venv/bin/activate |
113 | | - ``` |
| 126 | +!!! Abstract "" |
| 127 | + 在 MaxKB 项目根目录下依次执行以下命令,启动本地模型服务。 |
114 | 128 |
|
115 | | - 安装后端需要的依赖 |
| 129 | + ``` |
| 130 | + # 启动项目 |
| 131 | + python main.py dev local_model |
| 132 | + ``` |
116 | 133 |
|
117 | | - ``` |
118 | | - poetry install |
119 | | - ``` |
| 134 | +{width="500px"} |
120 | 135 |
|
121 | | - 启动项目 |
| 136 | +!!! Abstract "" |
| 137 | + 在 MaxKB 项目根目录下依次执行以下命令,启动异步任务服务。 |
122 | 138 |
|
123 | | - ``` |
124 | | - python main.py start |
125 | | - ``` |
| 139 | + ``` |
| 140 | + # 启动项目 |
| 141 | + python main.py dev celery |
| 142 | + ``` |
126 | 143 |
|
127 | | -## 6 常见问题 |
| 144 | +{width="500px"} |
128 | 145 |
|
129 | | -!!! Abstract "" |
130 | | - - 关于数据库版本 |
131 | | - ``` |
132 | | - postgresql:15.x |
133 | | - ``` |
134 | | - - 关于 Python 版本 |
135 | | - ``` |
136 | | - python:3.11.x |
137 | | - ``` |
138 | | - - database "maxkb" does not exist |
| 146 | +## 5 访问项目 |
139 | 147 |
|
140 | | - 数据库不存在需要创建一个与配置文件相同的数据库,默认名称为 maxkb。 |
| 148 | +!!! Abstract "" |
| 149 | + 前后端都启动成功后,就可以通过前端路由(前端启动出现的访问地址)在浏览器中进行访问。 |
141 | 150 |
|
142 | | - ``` |
143 | | - CREATE DATABASE "maxkb"; |
144 | | - \c "maxkb"; |
145 | | - CREATE EXTENSION "vector"; |
146 | | - ``` |
| 151 | + |
0 commit comments