-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VERSION 1.0.0b1 #147
VERSION 1.0.0b1 #147
Conversation
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
try: | ||
if default_port is not None: | ||
s.bind(("", default_port)) |
Check warning
Code scanning / CodeQL
Binding a socket to all network interfaces Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 months ago
To fix the problem, we need to bind the socket to a specific interface instead of all interfaces. This can be achieved by replacing the empty string (""
) with a specific IP address. If the specific IP address is not known or needs to be configurable, we can use an environment variable to set it.
- Modify the
assign_port
function to accept an additional parameter for the IP address. - Use this IP address to bind the socket instead of the empty string.
- Update the
defaults
dictionary to include a default IP address. - Ensure the IP address is read from the environment variables.
-
Copy modified line R9 -
Copy modified line R13 -
Copy modified line R16 -
Copy modified line R19 -
Copy modified line R25 -
Copy modified lines R31-R36
@@ -8,3 +8,3 @@ | ||
|
||
def assign_port(default_port=None): | ||
def assign_port(ip_address, default_port=None): | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
@@ -12,9 +12,9 @@ | ||
if default_port is not None: | ||
s.bind(("", default_port)) | ||
s.bind((ip_address, default_port)) | ||
return default_port | ||
else: | ||
s.bind(("", 0)) | ||
s.bind((ip_address, 0)) | ||
return s.getsockname()[1] | ||
except OSError: | ||
s.bind(("", 0)) | ||
s.bind((ip_address, 0)) | ||
return s.getsockname()[1] | ||
@@ -24,3 +24,3 @@ | ||
"LLMSTUDIO_ENGINE_HOST": "localhost", | ||
"LLMSTUDIO_ENGINE_PORT": str(assign_port(50001)), | ||
"LLMSTUDIO_ENGINE_PORT": str(assign_port("127.0.0.1", 50001)), | ||
} | ||
@@ -30,2 +30,8 @@ | ||
|
||
ENGINE_HOST = os.environ["LLMSTUDIO_ENGINE_HOST"] | ||
ENGINE_PORT = os.environ["LLMSTUDIO_ENGINE_PORT"] | ||
|
||
# Update the assign_port call to use the environment variable for the IP address | ||
ENGINE_PORT = str(assign_port(ENGINE_HOST, int(ENGINE_PORT))) | ||
|
||
ENGINE_HOST = os.environ["LLMSTUDIO_ENGINE_HOST"] |
s.bind(("", default_port)) | ||
return default_port | ||
else: | ||
s.bind(("", 0)) |
Check warning
Code scanning / CodeQL
Binding a socket to all network interfaces Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 months ago
To fix the problem, we need to bind the socket to a specific interface instead of all interfaces. This can be achieved by using a dedicated IP address for the interface we want to bind to. If the specific interface is not known or needs to be configurable, we can use an environment variable to specify the interface.
- Modify the
assign_port
function to accept an additional parameter for the interface IP address. - Use this parameter to bind the socket to the specified interface instead of all interfaces.
- Update the code to use a default interface IP address if none is provided.
-
Copy modified line R9 -
Copy modified line R13 -
Copy modified line R16 -
Copy modified line R19 -
Copy modified line R25
@@ -8,3 +8,3 @@ | ||
|
||
def assign_port(default_port=None): | ||
def assign_port(default_port=None, interface_ip="127.0.0.1"): | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
@@ -12,9 +12,9 @@ | ||
if default_port is not None: | ||
s.bind(("", default_port)) | ||
s.bind((interface_ip, default_port)) | ||
return default_port | ||
else: | ||
s.bind(("", 0)) | ||
s.bind((interface_ip, 0)) | ||
return s.getsockname()[1] | ||
except OSError: | ||
s.bind(("", 0)) | ||
s.bind((interface_ip, 0)) | ||
return s.getsockname()[1] | ||
@@ -24,3 +24,3 @@ | ||
"LLMSTUDIO_ENGINE_HOST": "localhost", | ||
"LLMSTUDIO_ENGINE_PORT": str(assign_port(50001)), | ||
"LLMSTUDIO_ENGINE_PORT": str(assign_port(50001, os.getenv("LLMSTUDIO_INTERFACE_IP", "127.0.0.1"))), | ||
} |
s.bind(("", 0)) | ||
return s.getsockname()[1] | ||
except OSError: | ||
s.bind(("", 0)) |
Check warning
Code scanning / CodeQL
Binding a socket to all network interfaces Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 months ago
To fix the problem, we should bind the socket to a specific interface rather than all interfaces. This can be achieved by replacing the empty string (""
) with a specific IP address. In this case, we will use localhost
(i.e., 127.0.0.1
) to restrict the socket to the local machine. This change will ensure that the socket only accepts connections from the local machine, thereby enhancing security.
-
Copy modified line R13 -
Copy modified line R16 -
Copy modified line R19
@@ -12,9 +12,9 @@ | ||
if default_port is not None: | ||
s.bind(("", default_port)) | ||
s.bind(("127.0.0.1", default_port)) | ||
return default_port | ||
else: | ||
s.bind(("", 0)) | ||
s.bind(("127.0.0.1", 0)) | ||
return s.getsockname()[1] | ||
except OSError: | ||
s.bind(("", 0)) | ||
s.bind(("127.0.0.1", 0)) | ||
return s.getsockname()[1] |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
try: | ||
if default_port is not None: | ||
s.bind(("", default_port)) |
Check warning
Code scanning / CodeQL
Binding a socket to all network interfaces Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 months ago
To fix the problem, we need to bind the socket to a specific network interface instead of all interfaces. This can be achieved by replacing the empty string ""
with a specific IP address. In this case, we will use the LLMSTUDIO_TRACKING_HOST
environment variable, which defaults to localhost
. This ensures that the socket is only accessible from the local machine, mitigating the security risk.
- Modify the
assign_port
function to accept an additional parameter for the host. - Use the
TRACKING_HOST
environment variable as the host when binding the socket.
-
Copy modified line R9 -
Copy modified line R13 -
Copy modified line R16 -
Copy modified line R19 -
Copy modified line R25
@@ -8,3 +8,3 @@ | ||
|
||
def assign_port(default_port=None): | ||
def assign_port(host, default_port=None): | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | ||
@@ -12,9 +12,9 @@ | ||
if default_port is not None: | ||
s.bind(("", default_port)) | ||
s.bind((host, default_port)) | ||
return default_port | ||
else: | ||
s.bind(("", 0)) | ||
s.bind((host, 0)) | ||
return s.getsockname()[1] | ||
except OSError: | ||
s.bind(("", 0)) | ||
s.bind((host, 0)) | ||
return s.getsockname()[1] | ||
@@ -24,3 +24,3 @@ | ||
"LLMSTUDIO_TRACKING_HOST": "localhost", | ||
"LLMSTUDIO_TRACKING_PORT": str(assign_port(50002)), | ||
"LLMSTUDIO_TRACKING_PORT": str(assign_port(os.getenv("LLMSTUDIO_TRACKING_HOST", "localhost"), 50002)), | ||
"LLMSTUDIO_TRACKING_URI": "sqlite:///./llmstudio_mgmt.db", |
s.bind(("", default_port)) | ||
return default_port | ||
else: | ||
s.bind(("", 0)) |
Check warning
Code scanning / CodeQL
Binding a socket to all network interfaces Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 months ago
To fix the problem, we need to bind the socket to a specific interface instead of all interfaces. This can be achieved by replacing the empty string ""
with a specific IP address, such as 127.0.0.1
(localhost), which limits the socket to accept connections only from the local machine.
- Update the
assign_port
function to bind the socket to127.0.0.1
instead of""
. - Ensure that the changes do not affect the existing functionality of dynamically assigning a port.
-
Copy modified line R13 -
Copy modified line R16 -
Copy modified line R19
@@ -12,9 +12,9 @@ | ||
if default_port is not None: | ||
s.bind(("", default_port)) | ||
s.bind(("127.0.0.1", default_port)) | ||
return default_port | ||
else: | ||
s.bind(("", 0)) | ||
s.bind(("127.0.0.1", 0)) | ||
return s.getsockname()[1] | ||
except OSError: | ||
s.bind(("", 0)) | ||
s.bind(("127.0.0.1", 0)) | ||
return s.getsockname()[1] |
s.bind(("", 0)) | ||
return s.getsockname()[1] | ||
except OSError: | ||
s.bind(("", 0)) |
Check warning
Code scanning / CodeQL
Binding a socket to all network interfaces Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 4 months ago
To fix the problem, we need to bind the socket to a specific network interface instead of all interfaces. This can be achieved by replacing the empty string (""
) with a specific IP address. In this case, we will use localhost
(127.0.0.1
) to bind the socket to the local interface, which is a common practice for services that do not need to be accessed from outside the host machine.
- Update the
assign_port
function to bind the socket to127.0.0.1
instead of an empty string. - Ensure that the socket is only accessible from the local machine, enhancing security.
-
Copy modified line R13 -
Copy modified line R16 -
Copy modified line R19
@@ -12,9 +12,9 @@ | ||
if default_port is not None: | ||
s.bind(("", default_port)) | ||
s.bind(("127.0.0.1", default_port)) | ||
return default_port | ||
else: | ||
s.bind(("", 0)) | ||
s.bind(("127.0.0.1", 0)) | ||
return s.getsockname()[1] | ||
except OSError: | ||
s.bind(("", 0)) | ||
s.bind(("127.0.0.1", 0)) | ||
return s.getsockname()[1] |
LLMstudio Version 1.0.0b1
What was done in this PR:
api_key
and accepts a structuredchat_request
. This restructuring also includes making the proxy and tracking optional for more flexible usage.session_id
tracking for chat sessions and logging support for better traceability.langgraph
.isort
andflake8
configurations, and updated pre-commit hooks.config.yaml
for easier configuration management and enhanced initialization for Azure-based clients.How it was tested:
session_id
integration for accuracy in tracking sessions and seamless functionality with logging tools.Additional notes:
Any breaking changes?
Yes, breaking changes were introduced in the LLM provider instantiation. The new instantiation now requires specifying parameters in the following format:
Any new dependencies added?
New dependencies are introduced to support modularization, API versioning, and enhanced testing, though specific package details should be checked in
pyproject.toml
.Any performance improvements?
Optimized API calls with parallel execution for tool calls, streamlined server components, and minimized function calls within the LLM provider, which should contribute to overall performance improvements.