Skip to content

Commit

Permalink
Allow setting fastapi root_path argument (vllm-project#2341)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragjn authored and hongxiayang committed Jan 18, 2024
1 parent 9117159 commit de180e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vllm/entrypoints/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ async def stream_results() -> AsyncGenerator[bytes, None]:
parser.add_argument("--port", type=int, default=8000)
parser.add_argument("--ssl-keyfile", type=str, default=None)
parser.add_argument("--ssl-certfile", type=str, default=None)
parser.add_argument(
"--root-path",
type=str,
default=None,
help="FastAPI root_path when app is behind a path based routing proxy")
parser = AsyncEngineArgs.add_cli_args(parser)
args = parser.parse_args()

engine_args = AsyncEngineArgs.from_cli_args(args)
engine = AsyncLLMEngine.from_engine_args(engine_args)

app.root_path = args.root_path
uvicorn.run(app,
host=args.host,
port=args.port,
Expand Down
6 changes: 6 additions & 0 deletions vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def parse_args():
type=str,
default=None,
help="The file path to the SSL cert file")
parser.add_argument(
"--root-path",
type=str,
default=None,
help="FastAPI root_path when app is behind a path based routing proxy")

parser = AsyncEngineArgs.add_cli_args(parser)
return parser.parse_args()
Expand Down Expand Up @@ -766,6 +771,7 @@ async def fake_stream_generator() -> AsyncGenerator[str, None]:
# Register labels for metrics
add_global_metrics_labels(model_name=engine_args.model)

app.root_path = args.root_path
uvicorn.run(app,
host=args.host,
port=args.port,
Expand Down

0 comments on commit de180e5

Please sign in to comment.