fix: correct LM Studio URL parsing and uvicorn port binding (fixes #394)

- lm_studio_fn: use urlparse to extract port from server_address so that
  addresses with an http:// prefix (e.g. http://127.0.0.1:1234, as
  documented in README) no longer break the Docker URL construction.
  Previously split(":")[1] returned "//127.0.0.1" instead of the port
  number, producing a malformed URL.
  Also fix the non-Docker path to avoid prepending http:// when the address
  already includes a scheme.

- api.py: pass the computed port variable to uvicorn.run() instead of the
  hardcoded literal 7777, so that BACKEND_PORT environment variable is
  actually honoured when starting the server directly.
This commit is contained in:
octo-patch
2026-04-11 10:37:17 +08:00
parent 31205febfe
commit 05aa5c2104
2 changed files with 13 additions and 5 deletions
+1 -1
View File
@@ -299,4 +299,4 @@ if __name__ == "__main__":
port = int(envport)
else:
port = 7777
uvicorn.run(api, host="0.0.0.0", port=7777)
uvicorn.run(api, host="0.0.0.0", port=port)