update llm_api_launch,api_allinone,webui_allinone,readme:1.llm_api_launch,api_allinone_webui_allinone更名;2. 更新readme关于startup的说明

This commit is contained in:
hzg0601 2023-08-17 16:59:16 +08:00
parent 6c9e3ddc21
commit 44d4bacf1c
5 changed files with 41 additions and 81 deletions

View File

@ -214,7 +214,6 @@ embedding_model_dict = {
```shell
$ python init_database.py
```
- 如果您是第一次运行本项目,知识库尚未建立,或者配置文件中的知识库类型、嵌入模型发生变化,需要以下命令初始化或重建知识库:
```shell
@ -244,6 +243,7 @@ $ python server/llm_api.py
```
项目支持多卡加载,需在 llm_api.py 中修改 create_model_worker_app 函数中,修改如下三个参数:
```python
gpus=None,
num_gpus=1,
@ -258,7 +258,7 @@ max_gpu_memory="20GiB"
##### 5.1.2 基于命令行脚本 llm_api_launch.py 启动 LLM 服务
⚠️ **注意:**
⚠️ **注意:**
**1.llm_api_launch.py脚本原生仅适用于linux,mac设备需要安装对应的linux命令,win平台请使用wls;**
@ -275,11 +275,13 @@ $ python server/llm_api_launch.py
```shell
$ python server/llm_api_launch.py --model-path-addresss model1@host1@port1 model2@host2@port2
```
如果出现server端口占用情况需手动指定server端口,并同步修改model_config.py下对应模型的base_api_url为指定端口:
```shell
$ python server/llm_api_launch.py --server-port 8887
```
如果要启动多卡加载,示例命令如下:
```shell
@ -354,7 +356,6 @@ $ streamlit run webui.py --server.port 666
- Web UI 对话界面:
![](img/webui_0813_0.png)
- Web UI 知识库管理页面:
![](img/webui_0813_1.png)
@ -363,86 +364,21 @@ $ streamlit run webui.py --server.port 666
### 6. 一键启动
⚠️ **注意:**
**1. 一键启动脚本仅原生适用于Linux,Mac 设备需要安装对应的linux命令, Winodws 平台请使用 WLS;**
**2. 加载非默认模型需要用命令行参数 `--model-path-address` 指定模型,不会读取 `model_config.py` 配置。**
#### 6.1 API 服务一键启动脚本
新增 API 一键启动脚本,可一键开启 FastChat 后台服务及本项目提供的 API 服务,调用示例:
调用默认模型:
更新一键启动脚本startup.py,一键启动所有fastchat服务、API服务、WebUI服务实例
```shell
$ python server/api_allinone.py
$ python startup.py --all-webui
```
加载多个非默认模型:
可选 `all-webui,all-api,llm-api,controller,openai-api,model-worker,api,webui`.
若想指定非默认模型,需要用--model-name选项示例
```shell
$ python server/api_allinone.py --model-path-address model1@host1@port1 model2@host2@port2
$ python startup.py --all-webui --model-name Qwen-7B-Chat
```
如果出现server端口占用情况需手动指定server端口,并同步修改model_config.py下对应模型的base_api_url为指定端口:
```shell
$ python server/api_allinone.py --server-port 8887
```
多卡启动:
```shell
python server/api_allinone.py --model-path-address model@host@port --num-gpus 2 --gpus 0,1 --max-gpu-memory 10GiB
```
其他参数详见各脚本及 FastChat 服务说明。
#### 6.2 webui一键启动脚本
加载本地模型:
```shell
$ python webui_allinone.py
```
调用远程 API 服务:
```shell
$ python webui_allinone.py --use-remote-api
```
如果出现server端口占用情况需手动指定server端口,并同步修改model_config.py下对应模型的base_api_url为指定端口:
```shell
$ python webui_allinone.py --server-port 8887
```
后台运行webui服务
```shell
$ python webui_allinone.py --nohup
```
加载多个非默认模型:
```shell
$ python webui_allinone.py --model-path-address model1@host1@port1 model2@host2@port2
```
多卡启动:
```shell
$ python webui_alline.py --model-path-address model@host@port --num-gpus 2 --gpus 0,1 --max-gpu-memory 10GiB
```
其他参数详见各脚本及 Fastchat 服务说明。
上述两个一键启动脚本会后台运行多个服务,如要停止所有服务,可使用 `shutdown_all.sh` 脚本:
```shell
bash shutdown_all.sh
```
**注意startup脚本用多进程方式启动各模块的服务可能会导致打印顺序问题请等待全部服务发起后再调用并根据默认端口调用服务默认api服务端口127.0.0.1:7861,默认webui服务端口`本机IP8501`)**
## 常见问题

View File

@ -15,7 +15,7 @@ import os
sys.path.append(os.path.dirname(__file__))
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
from llm_api_launch import launch_all, parser, controller_args, worker_args, server_args
from llm_api_stale import launch_all, parser, controller_args, worker_args, server_args
from api import create_app
import uvicorn

View File

@ -20,9 +20,9 @@ from webui_pages.utils import *
from streamlit_option_menu import option_menu
from webui_pages import *
import os
from server.llm_api_launch import string_args,launch_all,controller_args,worker_args,server_args,LOG_PATH
from server.llm_api_stale import string_args,launch_all,controller_args,worker_args,server_args,LOG_PATH
from server.api_allinone import parser, api_args
from server.api_allinone_stale import parser, api_args
import subprocess
parser.add_argument("--use-remote-api",action="store_true")

View File

@ -249,8 +249,19 @@ def run_webui(q: Queue, run_seq: int = 5):
def parse_args() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser()
parser.add_argument(
"-a",
"--all",
"--all-webui",
action="store_true",
help="run fastchat's controller/model_worker/openai_api servers, run api.py and webui.py",
dest="all",
)
parser.add_argument(
"--all-api",
action="store_true",
help="run fastchat's controller/model_worker/openai_api servers, run api.py and webui.py",
dest="all",
)
parser.add_argument(
"--llm-api",
action="store_true",
help="run fastchat's controller/model_worker/openai_api servers, run api.py and webui.py",
dest="all",
@ -305,12 +316,25 @@ if __name__ == "__main__":
mp.set_start_method("spawn")
queue = Queue()
args = parse_args()
if args.all:
if args.all_webui:
args.openai_api = True
args.model_worker = True
args.api = True
args.webui = True
elif args.all_api:
args.openai_api = True
args.model_worker = True
args.api = True
args.webui = False
elif args.llm_api:
args.openai_api = True
args.model_worker = True
args.api = False
args.webui = False
logger.info(f"正在启动服务:")
logger.info(f"如需查看 llm_api 日志,请前往 {LOG_PATH}")