Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: server memory leak (#1751)
Charles Packer8cf08e0245e8
diff --git a/memgpt/server/rest_api/app.py b/memgpt/server/rest_api/app.pyindex b4d08ef9e..c635f96e5 100644--- a/memgpt/server/rest_api/app.py+++ b/memgpt/server/rest_api/app.py@@ -38,7 +38,7 @@ from memgpt.settings import settings# TODO(ethan)# NOTE(charles): @ethan I had to add this to get the global as the bottom to workinterface: StreamingServerInterface = StreamingServerInterface-server: SyncServer = SyncServer(default_interface_factory=lambda: interface())+server: SyncServer = None# TODO(ethan): eventuall removeif password := settings.server_pass:@@ -57,6 +57,8 @@ OPENAI_API_PREFIX = "/openai"def create_application() -> "FastAPI":"""the application start routine"""+ global server+ server = SyncServer(default_interface_factory=lambda: interface())app = FastAPI(swagger_ui_parameters={"docExpansion": "none"},diff --git a/memgpt/server/rest_api/utils.py b/memgpt/server/rest_api/utils.pyindex fdbccdc70..bd416e534 100644--- a/memgpt/server/rest_api/utils.py+++ b/memgpt/server/rest_api/utils.py@@ -58,7 +58,10 @@ async def sse_async_generator(generator: AsyncGenerator, finish_message=True):# TODO: why does this double up the interface?def get_memgpt_server() -> SyncServer:- server = SyncServer(default_interface_factory=lambda: StreamingServerInterface())+ # Check if a global server is already instantiated+ from memgpt.server.rest_api.app import server++ assert isinstance(server, SyncServer)return server