diff --git a/pyproject.toml b/pyproject.toml index 77187023..15c61268 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,8 @@ authors = ["Relevance Team "] readme = "README.md" license = "Apache-2.0" packages = [{include = "canopy", from = "src"}, - {include = "canopy_cli", from = "src"},] + {include = "canopy_cli", from = "src"}, + {include = "canopy_server", from = "src"},] [tool.poetry.dependencies] python = "^3.9" diff --git a/src/canopy_cli/cli.py b/src/canopy_cli/cli.py index 7fcf8757..bee46cfe 100644 --- a/src/canopy_cli/cli.py +++ b/src/canopy_cli/cli.py @@ -28,9 +28,9 @@ from canopy import __version__ -from .app import start as start_service +from canopy_server.app import start as start_service from .cli_spinner import Spinner -from .api_models import ChatDebugInfo +from canopy_server.api_models import ChatDebugInfo load_dotenv() @@ -479,7 +479,7 @@ def start(host: str, port: str, reload: bool, config: Optional[str]): "🚨 Note 🚨\n" "For debugging only. To run the Canopy service in production, run the command:" "\n" - "gunicorn canopy_cli.app:app --worker-class uvicorn.workers.UvicornWorker " + "gunicorn canopy_server.app:app --worker-class uvicorn.workers.UvicornWorker " f"--bind {host}:{port} --workers " ) for c in note_msg: @@ -504,7 +504,7 @@ def start(host: str, port: str, reload: bool, config: Optional[str]): help="URL of the Canopy service to use. Defaults to http://0.0.0.0:8000") def stop(url): # Check if the service was started using Gunicorn - res = subprocess.run(["pgrep", "-f", "gunicorn canopy_cli.app:app"], + res = subprocess.run(["pgrep", "-f", "gunicorn canopy_server.app:app"], capture_output=True) output = res.stdout.decode("utf-8").split() @@ -514,7 +514,7 @@ def stop(url): "Do you want to kill all Gunicorn processes?") click.confirm(click.style(msg, fg="red"), abort=True) try: - subprocess.run(["pkill", "-f", "gunicorn canopy_cli.app:app"], check=True) + subprocess.run(["pkill", "-f", "gunicorn canopy_server.app:app"], check=True) except subprocess.CalledProcessError: try: [os.kill(int(pid), signal.SIGINT) for pid in output] diff --git a/src/canopy_server/__init__.py b/src/canopy_server/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/canopy_cli/api_models.py b/src/canopy_server/api_models.py similarity index 100% rename from src/canopy_cli/api_models.py rename to src/canopy_server/api_models.py diff --git a/src/canopy_cli/app.py b/src/canopy_server/app.py similarity index 97% rename from src/canopy_cli/app.py rename to src/canopy_server/app.py index c2f54903..a135754c 100644 --- a/src/canopy_cli/app.py +++ b/src/canopy_server/app.py @@ -25,9 +25,9 @@ from canopy.models.api_models import StreamingChatResponse, ChatResponse from canopy.models.data_models import Context -from canopy_cli.api_models import \ - ChatRequest, ContextQueryRequest, \ - ContextUpsertRequest, HealthStatus, ContextDeleteRequest +from .api_models import \ + ChatRequest, ContextQueryRequest, \ + ContextUpsertRequest, HealthStatus, ContextDeleteRequest from canopy.llm.openai import OpenAILLM from canopy_cli.errors import ConfigError @@ -260,7 +260,7 @@ def start(host="0.0.0.0", port=8000, reload=False, config_file=None): if config_file: os.environ["CANOPY_CONFIG_FILE"] = config_file - uvicorn.run("canopy_cli.app:app", host=host, port=port, reload=reload, workers=0) + uvicorn.run("canopy_server.app:app", host=host, port=port, reload=reload, workers=0) if __name__ == "__main__": diff --git a/tests/e2e/test_app.py b/tests/e2e/test_app.py index 6bcf191c..b37af3e6 100644 --- a/tests/e2e/test_app.py +++ b/tests/e2e/test_app.py @@ -10,9 +10,9 @@ from canopy.knowledge_base import KnowledgeBase -from canopy_cli.app import app -from canopy_cli.api_models import (HealthStatus, ContextUpsertRequest, - ContextQueryRequest) +from canopy_server.app import app +from canopy_server.api_models import (HealthStatus, ContextUpsertRequest, + ContextQueryRequest) from .. import Tokenizer upsert_payload = ContextUpsertRequest(