From 43532dbe17ce49a88edc2312b63608e75a9ff94a Mon Sep 17 00:00:00 2001 From: stephanbertl Date: Sun, 24 Dec 2023 06:56:33 +0100 Subject: [PATCH] add root_path argument to gradio web server. (#2807) Co-authored-by: bertls --- fastchat/serve/gradio_web_server.py | 6 ++++++ fastchat/serve/gradio_web_server_multi.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/fastchat/serve/gradio_web_server.py b/fastchat/serve/gradio_web_server.py index 5abab5917..aaf8b1fb9 100644 --- a/fastchat/serve/gradio_web_server.py +++ b/fastchat/serve/gradio_web_server.py @@ -835,6 +835,11 @@ def build_demo(models): type=str, help='Set the gradio authentication file path. The file should contain one or more user:password pairs in this format: "u1:p1,u2:p2,u3:p3"', ) + parser.add_argument( + "--gradio-root-path", + type=str, + help="Sets the gradio root path, eg /abc/def. Useful when running behind a reverse-proxy or at a custom URL path prefix" + ) args = parser.parse_args() logger.info(f"args: {args}") @@ -863,4 +868,5 @@ def build_demo(models): share=args.share, max_threads=200, auth=auth, + root_path=args.gradio_root_path ) diff --git a/fastchat/serve/gradio_web_server_multi.py b/fastchat/serve/gradio_web_server_multi.py index ea46f5874..d0e1f87c1 100644 --- a/fastchat/serve/gradio_web_server_multi.py +++ b/fastchat/serve/gradio_web_server_multi.py @@ -228,6 +228,11 @@ def build_demo(models, elo_results_file, leaderboard_table_file): parser.add_argument( "--leaderboard-table-file", type=str, help="Load leaderboard results and plots" ) + parser.add_argument( + "--gradio-root-path", + type=str, + help="Sets the gradio root path, eg /abc/def. Useful when running behind a reverse-proxy or at a custom URL path prefix" + ) args = parser.parse_args() logger.info(f"args: {args}") @@ -267,4 +272,5 @@ def build_demo(models, elo_results_file, leaderboard_table_file): share=args.share, max_threads=200, auth=auth, + root_path=args.gradio_root_path )