Skip to content

Commit

Permalink
Now the proxy works right, yay
Browse files Browse the repository at this point in the history
  • Loading branch information
jmather committed Aug 29, 2024
1 parent 87de911 commit 85f6a6a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 6 deletions.
Empty file added __init__.py
Empty file.
6 changes: 6 additions & 0 deletions bin/build-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

rm -rf dist build

python setup.py develop

4 changes: 4 additions & 0 deletions bin/install-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

pip uninstall llmhub-cli -y
pip install -e .
15 changes: 12 additions & 3 deletions cli/manage.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
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")

@click.command()
@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()
Expand All @@ -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()
Expand All @@ -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:
Expand Down
Binary file modified llmhub_lib/__pycache__/actions.cpython-310.pyc
Binary file not shown.
12 changes: 11 additions & 1 deletion llmhub_lib/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import importlib.resources as new_pkg_resources

def update_processes(service_manager):
service_manager.update_services()
Expand All @@ -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:
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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",
Expand Down

0 comments on commit 85f6a6a

Please sign in to comment.