"vscode:/vscode.git/clone" did not exist on "04c30254d4bd16b07958110165f59e9ac9fbf5c6"
cli_args.py 4.95 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
"""
This file contains the command line arguments for the vLLM's
OpenAI-compatible server. It is kept in a separate file for documentation
purposes.
"""

import argparse
import json
import ssl

11
from vllm.engine.arg_utils import AsyncEngineArgs, nullable_str
12
from vllm.entrypoints.openai.serving_engine import LoRAModulePath
13
14
15
16
17
18
19
20


class LoRAParserAction(argparse.Action):

    def __call__(self, parser, namespace, values, option_string=None):
        lora_list = []
        for item in values:
            name, path = item.split('=')
21
            lora_list.append(LoRAModulePath(name, path))
22
23
24
25
26
27
        setattr(namespace, self.dest, lora_list)


def make_arg_parser():
    parser = argparse.ArgumentParser(
        description="vLLM OpenAI-Compatible RESTful API server.")
28
29
30
31
    parser.add_argument("--host",
                        type=nullable_str,
                        default=None,
                        help="host name")
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    parser.add_argument("--port", type=int, default=8000, help="port number")
    parser.add_argument(
        "--uvicorn-log-level",
        type=str,
        default="info",
        choices=['debug', 'info', 'warning', 'error', 'critical', 'trace'],
        help="log level for uvicorn")
    parser.add_argument("--allow-credentials",
                        action="store_true",
                        help="allow credentials")
    parser.add_argument("--allowed-origins",
                        type=json.loads,
                        default=["*"],
                        help="allowed origins")
    parser.add_argument("--allowed-methods",
                        type=json.loads,
                        default=["*"],
                        help="allowed methods")
    parser.add_argument("--allowed-headers",
                        type=json.loads,
                        default=["*"],
                        help="allowed headers")
    parser.add_argument("--api-key",
55
                        type=nullable_str,
56
57
58
59
                        default=None,
                        help="If provided, the server will require this key "
                        "to be presented in the header.")
    parser.add_argument("--served-model-name",
60
                        nargs="+",
61
                        type=nullable_str,
62
                        default=None,
63
64
65
66
67
68
                        help="The model name(s) used in the API. If multiple "
                        "names are provided, the server will respond to any "
                        "of the provided names. The model name in the model "
                        "field of a response will be the first name in this "
                        "list. If not specified, the model name will be the "
                        "same as the `--model` argument.")
69
70
    parser.add_argument(
        "--lora-modules",
71
        type=nullable_str,
72
73
74
75
76
77
        default=None,
        nargs='+',
        action=LoRAParserAction,
        help="LoRA module configurations in the format name=path. "
        "Multiple modules can be specified.")
    parser.add_argument("--chat-template",
78
                        type=nullable_str,
79
80
81
82
83
                        default=None,
                        help="The file path to the chat template, "
                        "or the template in single-line form "
                        "for the specified model")
    parser.add_argument("--response-role",
84
                        type=nullable_str,
85
86
87
88
                        default="assistant",
                        help="The role name to return if "
                        "`request.add_generation_prompt=true`.")
    parser.add_argument("--ssl-keyfile",
89
                        type=nullable_str,
90
91
92
                        default=None,
                        help="The file path to the SSL key file")
    parser.add_argument("--ssl-certfile",
93
                        type=nullable_str,
94
95
96
                        default=None,
                        help="The file path to the SSL cert file")
    parser.add_argument("--ssl-ca-certs",
97
                        type=nullable_str,
98
99
100
101
102
103
104
105
106
107
                        default=None,
                        help="The CA certificates file")
    parser.add_argument(
        "--ssl-cert-reqs",
        type=int,
        default=int(ssl.CERT_NONE),
        help="Whether client certificate is required (see stdlib ssl module's)"
    )
    parser.add_argument(
        "--root-path",
108
        type=nullable_str,
109
110
111
112
        default=None,
        help="FastAPI root_path when app is behind a path based routing proxy")
    parser.add_argument(
        "--middleware",
113
        type=nullable_str,
114
115
116
117
118
119
120
121
122
123
124
125
        action="append",
        default=[],
        help="Additional ASGI middleware to apply to the app. "
        "We accept multiple --middleware arguments. "
        "The value should be an import path. "
        "If a function is provided, vLLM will add it to the server "
        "using @app.middleware('http'). "
        "If a class is provided, vLLM will add it to the server "
        "using app.add_middleware(). ")

    parser = AsyncEngineArgs.add_cli_args(parser)
    return parser