diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/bin/build-dev.sh b/bin/build-dev.sh new file mode 100755 index 0000000..bcc8b00 --- /dev/null +++ b/bin/build-dev.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +rm -rf dist build + +python setup.py develop + diff --git a/bin/install-dev.sh b/bin/install-dev.sh new file mode 100755 index 0000000..4e11811 --- /dev/null +++ b/bin/install-dev.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +pip uninstall llmhub-cli -y +pip install -e . diff --git a/cli/manage.py b/cli/manage.py index 4d180dc..20515a6 100644 --- a/cli/manage.py +++ b/cli/manage.py @@ -1,5 +1,6 @@ import click from llmhub_lib.app_dependency_container import AppDependencyContainer +from llmhub_lib.helpers import start_proxy_process, stop_proxy_process service_manager = AppDependencyContainer.get("service_manager") @@ -7,7 +8,9 @@ @click.argument('model_name', required=False) def start(model_name=None): """Start a specific model process or all processes if no model_name is provided.""" - if model_name: + if model_name.startswith("proxy-"): + start_proxy_process(service_manager) + elif model_name: service_manager.start_service(model_name, quant="Q5_K_M") # Example quant value else: service_manager.update_services() @@ -16,7 +19,10 @@ def start(model_name=None): @click.argument('model_name', required=False) def stop(model_name=None): """Stop a specific process or all processes if no model_name is provided.""" - if model_name: + # Stop the proxy process if the model_name starts with "proxy-" + if model_name.startswith("proxy-"): + stop_proxy_process(service_manager) + elif model_name: service_manager.stop_service(model_name) else: service_manager.stop_all_services() @@ -25,7 +31,10 @@ def stop(model_name=None): @click.argument('model_name', required=False) def restart(model_name=None): """Restart a specific process or all processes if no model_name is provided.""" - if model_name: + if model_name.startswith("proxy-"): + stop_proxy_process(service_manager) + start_proxy_process(service_manager) + elif model_name: service_manager.stop_service(model_name) service_manager.start_service(model_name, quant="Q5_K_M") # Example quant value else: diff --git a/llmhub_lib/__pycache__/actions.cpython-310.pyc b/llmhub_lib/__pycache__/actions.cpython-310.pyc index 888054e..63a32eb 100644 Binary files a/llmhub_lib/__pycache__/actions.cpython-310.pyc and b/llmhub_lib/__pycache__/actions.cpython-310.pyc differ diff --git a/llmhub_lib/helpers.py b/llmhub_lib/helpers.py index af58c8f..8a7065c 100644 --- a/llmhub_lib/helpers.py +++ b/llmhub_lib/helpers.py @@ -1,5 +1,6 @@ import os import sys +import importlib.resources as new_pkg_resources def update_processes(service_manager): service_manager.update_services() @@ -23,7 +24,16 @@ def start_proxy_process(service_manager): if proxy_process_name not in running_processes: # Determine the path to the web_server.py file dynamically - script_path = os.path.join(os.path.dirname(__file__ + '/..'), 'web_server.py') + try: + script_path = new_pkg_resources.files('llmhub_lib').joinpath('web_server.py') + except AttributeError: + # Fallback for older Python versions + import pkg_resources + script_path = pkg_resources.resource_filename('llmhub_lib', 'web_server.py') + + if not os.path.isfile(script_path): + raise FileNotFoundError(f"web_server.py not found at {script_path}") + proxy_cmd = [sys.executable, str(script_path)] service_manager.process_manager.start_process(proxy_cmd, proxy_process_name, web_port) else: diff --git a/web_server.py b/llmhub_lib/web_server.py similarity index 100% rename from web_server.py rename to llmhub_lib/web_server.py diff --git a/setup.py b/setup.py index 9b98614..8a367df 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="llmhub-cli", - version="0.1.5", + version="0.1.6", author="Jacob Mather", author_email="jmather@jmather.com", description="LLMHub is a lightweight management platform designed to streamline working with LLMs.", @@ -24,7 +24,7 @@ ], }, package_data={ - '': ['web_server.py'], # Include the web_server.py file in the package + 'llmhub_lib': ['web_server.py'], # Include the web_server.py file in the package }, classifiers=[ "Programming Language :: Python :: 3",