From 3fa1a295ba7f5ccdb436bc8920669bd62cd96ae1 Mon Sep 17 00:00:00 2001 From: jnjpng Date: Fri, 9 May 2025 11:39:43 -0700 Subject: [PATCH] build: add hot reload config for core letta server (#2093) --- letta/cli/cli.py | 3 ++- letta/server/rest_api/app.py | 5 +++-- project.json | 11 +++++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/letta/cli/cli.py b/letta/cli/cli.py index 6dd4e609..a89d5266 100644 --- a/letta/cli/cli.py +++ b/letta/cli/cli.py @@ -42,6 +42,7 @@ def server( port: Annotated[Optional[int], typer.Option(help="Port to run the server on")] = None, host: Annotated[Optional[str], typer.Option(help="Host to run the server on (default to localhost)")] = None, debug: Annotated[bool, typer.Option(help="Turn debugging output on")] = False, + reload: Annotated[bool, typer.Option(help="Enable hot-reload")] = False, ade: Annotated[bool, typer.Option(help="Allows remote access")] = False, # NOTE: deprecated secure: Annotated[bool, typer.Option(help="Adds simple security access")] = False, localhttps: Annotated[bool, typer.Option(help="Setup local https")] = False, @@ -61,7 +62,7 @@ def server( try: from letta.server.rest_api.app import start_server - start_server(port=port, host=host, debug=debug) + start_server(port=port, host=host, debug=debug, reload=reload) except KeyboardInterrupt: # Handle CTRL-C diff --git a/letta/server/rest_api/app.py b/letta/server/rest_api/app.py index caaaf3d0..f2d96bc1 100644 --- a/letta/server/rest_api/app.py +++ b/letta/server/rest_api/app.py @@ -333,6 +333,7 @@ def start_server( port: Optional[int] = None, host: Optional[str] = None, debug: bool = False, + reload: bool = False, ): """Convenience method to start the server from within Python""" if debug: @@ -356,7 +357,7 @@ def start_server( host=host or "localhost", port=port or REST_DEFAULT_PORT, workers=settings.uvicorn_workers, - reload=settings.uvicorn_reload, + reload=reload or settings.uvicorn_reload, timeout_keep_alive=settings.uvicorn_timeout_keep_alive, ssl_keyfile="certs/localhost-key.pem", ssl_certfile="certs/localhost.pem", @@ -375,6 +376,6 @@ def start_server( host=host or "localhost", port=port or REST_DEFAULT_PORT, workers=settings.uvicorn_workers, - reload=settings.uvicorn_reload, + reload=reload or settings.uvicorn_reload, timeout_keep_alive=settings.uvicorn_timeout_keep_alive, ) diff --git a/project.json b/project.json index 217724ab..fbbade4e 100644 --- a/project.json +++ b/project.json @@ -34,6 +34,17 @@ "cwd": "apps/core" } }, + "debug": { + "executor": "@nxlv/python:run-commands", + "options": { + "commands": [ + "./otel/start-otel-collector.sh", + "poetry run letta server --debug --reload" + ], + "parallel": true, + "cwd": "apps/core" + } + }, "build": { "executor": "@nxlv/python:build", "outputs": ["{projectRoot}/dist"],