diff --git a/tools/api_server.py b/tools/api_server.py index 999fe4b9..c4054b30 100644 --- a/tools/api_server.py +++ b/tools/api_server.py @@ -1,3 +1,4 @@ +import re from threading import Lock import pyrootutils @@ -98,9 +99,14 @@ async def initialize_app(self, app: Kui): # Instead, it's better to use multiprocessing or independent models per thread. if __name__ == "__main__": - api = API() - host, port = api.args.listen.split(":") + + # IPv6 address format is [xxxx:xxxx::xxxx]:port + match = re.search(r"\[([^\]]+)\]:(\d+)$", api.args.listen) + if match: + host, port = match.groups() # IPv6 + else: + host, port = api.args.listen.split(":") # IPv4 uvicorn.run( api.app,