Skip to content

Commit

Permalink
Merge pull request #29 from smalltong02/RAG_dev1.0.1
Browse files Browse the repository at this point in the history
fix localhost issue.
  • Loading branch information
smalltong02 committed Feb 12, 2024
2 parents e79210d + 93cc0d5 commit 52bfc48
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions WebUI/Server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ async def wrap_done(fn: Awaitable, event: asyncio.Event):
# Signal the aiter to stop.
event.set()

def getlocalip(host : str = "127.0.0.1"):
if host == "0.0.0.0":
return "127.0.0.1"
return host

def fschat_controller_address() -> str:
host = FSCHAT_CONTROLLER["host"]
if host == "0.0.0.0":
Expand Down Expand Up @@ -209,7 +214,7 @@ def get_model_worker_config(model_name: str = None) -> dict:
webui_config = configinst.dump()
server_config = webui_config.get("ServerConfig")

config["host"] = server_config.get("default_host_ip")
config["host"] = getlocalip(server_config.get("default_host_ip"))
config["port"] = server_config["fastchat_model_worker"]["default"].get("port")
config["vllm_enable"] = server_config["fastchat_model_worker"]["default"].get("vllm_enable")

Expand Down Expand Up @@ -250,7 +255,7 @@ def get_vtot_worker_config(model_name: str = None) -> dict:
configinst = InnerJsonConfigWebUIParse()
webui_config = configinst.dump()
server_config = webui_config.get("ServerConfig")
config["host"] = server_config.get("default_host_ip")
config["host"] = getlocalip(server_config.get("default_host_ip"))
config["port"] = server_config["vtot_model_worker"].get("port")

if model_name is None or model_name == "":
Expand Down Expand Up @@ -282,7 +287,7 @@ def get_speech_worker_config(model_name: str = None) -> dict:
configinst = InnerJsonConfigWebUIParse()
webui_config = configinst.dump()
server_config = webui_config.get("ServerConfig")
config["host"] = server_config.get("default_host_ip")
config["host"] = getlocalip(server_config.get("default_host_ip"))
config["port"] = server_config["ttov_model_worker"].get("port")

if model_name is None or model_name == "":
Expand Down Expand Up @@ -314,7 +319,7 @@ def get_image_recognition_worker_config(model_name: str = None) -> dict:
configinst = InnerJsonConfigWebUIParse()
webui_config = configinst.dump()
server_config = webui_config.get("ServerConfig")
config["host"] = server_config.get("default_host_ip")
config["host"] = getlocalip(server_config.get("default_host_ip"))
config["port"] = server_config["image_recognition_worker"].get("port")

if model_name is None or model_name == "":
Expand All @@ -340,7 +345,7 @@ def get_image_generation_worker_config(model_name: str = None) -> dict:
configinst = InnerJsonConfigWebUIParse()
webui_config = configinst.dump()
server_config = webui_config.get("ServerConfig")
config["host"] = server_config.get("default_host_ip")
config["host"] = getlocalip(server_config.get("default_host_ip"))
config["port"] = server_config["image_generation_worker"].get("port")

if model_name is None or model_name == "":
Expand Down
2 changes: 1 addition & 1 deletion WebUI/configs/serverconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
OPEN_CROSS_DOMAIN = False

# The server will listen on all available network interfaces.
DEFAULT_BIND_HOST = "127.0.0.1"
DEFAULT_BIND_HOST = "0.0.0.0"

#webui server
WEBUI_SERVER = {
Expand Down
2 changes: 1 addition & 1 deletion WebUI/configs/webuiconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@
}
},
"ServerConfig": {
"default_host_ip": "127.0.0.1",
"default_host_ip": "0.0.0.0",
"default_timeout": 300,
"load_timeout": 120,
"release_timeout": 60,
Expand Down
2 changes: 2 additions & 0 deletions webuisrv.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def __init__(self):
def launch(self, started_event: mp.Event = None, run_mode: str = None):
host = WEBUI_SERVER["host"]
port = WEBUI_SERVER["port"]
if host == "0.0.0.0":
host = "localhost"

cmd = ["streamlit", "run", "webui.py",
"--server.address", host,
Expand Down

0 comments on commit 52bfc48

Please sign in to comment.