Skip to content

Commit

Permalink
BUG: incorrect endpoint on host 0.0.0.0 (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
UranusSeven authored Sep 21, 2023
1 parent 59b9458 commit b94f3cb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions xinference/core/restful_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ class RegisterModelRequest(BaseModel):


class RESTfulAPIActor(xo.Actor):
def __init__(self, sockets: List[socket.socket], endpoint: str):
def __init__(self, sockets: List[socket.socket], internal_endpoint: str):
super().__init__()
self._supervisor_ref: xo.ActorRefType["SupervisorActor"]
self._sockets = sockets
self._endpoint = endpoint
self._internal_endpoint = internal_endpoint
self._router = None
self._app = None

Expand Down Expand Up @@ -436,7 +436,7 @@ def build_interface(self, model_uid: str):
but calling API in async function does not return
"""
assert self._app is not None
assert self._endpoint is not None
assert self._internal_endpoint is not None

from .chat_interface import LLMInterface

Expand All @@ -453,7 +453,7 @@ def build_interface(self, model_uid: str):
asyncio.set_event_loop(asyncio.new_event_loop())

try:
interface = LLMInterface(self._endpoint, model_uid)
interface = LLMInterface(self._internal_endpoint, model_uid)
gr.mount_gradio_app(self._app, interface.build(), f"/{model_uid}")
except ValueError as ve:
logger.error(str(ve), exc_info=True)
Expand Down
6 changes: 2 additions & 4 deletions xinference/deploy/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,13 @@ async def start_supervisor_components(address: str, host: str, port: int):
else:
raise

if host == "0.0.0.0":
host = "localhost"

internal_host = "localhost" if host == "0.0.0.0" else host
restful_actor = await xo.create_actor(
RESTfulAPIActor,
address=address,
uid=RESTfulAPIActor.uid(),
sockets=sockets,
endpoint=f"http://{host}:{port}",
internal_endpoint=f"http://{internal_host}:{port}",
)
await restful_actor.serve()
url = f"http://{host}:{port}"
Expand Down

0 comments on commit b94f3cb

Please sign in to comment.