Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
removing dead code to make it easier to refactor
Ethan Knox8ba3b29352af
diff --git a/memgpt/config.py b/memgpt/config.pyindex 0a21faf7c..734485a59 100644--- a/memgpt/config.py+++ b/memgpt/config.py@@ -60,6 +60,9 @@ class MemGPTConfig:# embedding parametersdefault_embedding_config: EmbeddingConfig = None+# NONE OF THIS IS CONFIG ↓↓↓↓↓+# @norton120 these are the metdadatastore+# database configs: archivalarchival_storage_type: str = "chroma" # local, dbarchival_storage_path: str = os.path.join(MEMGPT_DIR, "chroma")diff --git a/memgpt/server/server.py b/memgpt/server/server.pyindex c0fac7d1e..9bde5d3b1 100644--- a/memgpt/server/server.py+++ b/memgpt/server/server.py@@ -112,7 +112,6 @@ class Server(object):user_id: str,agent_config: Union[dict, AgentState],interface: Union[AgentInterface, None],- # persistence_manager: Union[PersistenceManager, None],) -> str:"""Create a new agent using a config"""raise NotImplementedError@@ -136,49 +135,7 @@ class Server(object):raise NotImplementedError-class LockingServer(Server):- """Basic support for concurrency protections (all requests that modify an agent lock the agent until the operation is complete)"""-- # Locks for each agent- _agent_locks = {}-- @staticmethod- def agent_lock_decorator(func: Callable) -> Callable:- @wraps(func)- def wrapper(self, user_id: str, agent_id: str, *args, **kwargs):- # logger.info("Locking check")-- # Initialize the lock for the agent_id if it doesn't exist- if agent_id not in self._agent_locks:- # logger.info(f"Creating lock for agent_id = {agent_id}")- self._agent_locks[agent_id] = Lock()-- # Check if the agent is currently locked- if not self._agent_locks[agent_id].acquire(blocking=False):- # logger.info(f"agent_id = {agent_id} is busy")- raise HTTPException(status_code=423, detail=f"Agent '{agent_id}' is currently busy.")-- try:- # Execute the function- # logger.info(f"running function on agent_id = {agent_id}")- return func(self, user_id, agent_id, *args, **kwargs)- finally:- # Release the lock- # logger.info(f"releasing lock on agent_id = {agent_id}")- self._agent_locks[agent_id].release()-- return wrapper-- # @agent_lock_decorator- def user_message(self, user_id: str, agent_id: str, message: str) -> None:- raise NotImplementedError-- # @agent_lock_decorator- def run_command(self, user_id: str, agent_id: str, command: str) -> Union[str, None]:- raise NotImplementedError---class SyncServer(LockingServer):+class SyncServer(Server):"""Simple single-threaded / blocking server process"""def __init__(@@ -192,26 +149,6 @@ class SyncServer(LockingServer):):"""Server process holds in-memory agents that are being run"""- # Server supports several auth modes:- # "none":- # no authentication, trust the incoming requests to have access to the user_id being modified- # "jwt_local":- # clients send bearer JWT tokens, which decode to user_ids- # JWT tokens are generated by the server process (using pyJWT) and stored in a database table- # "jwt_external":- # clients still send bearer JWT tokens, but token generation and validation is handled by an external service- # ie the server process will call 'external.decode(token)' to get the user_id- # if auth_mode == "none":- # self.auth_mode = auth_mode- # raise NotImplementedError # TODO- # elif auth_mode == "jwt_local":- # self.auth_mode = auth_mode- # elif auth_mode == "jwt_external":- # self.auth_mode = auth_mode- # raise NotImplementedError # TODO- # else:- # raise ValueError(auth_mode)-# List of {'user_id': user_id, 'agent_id': agent_id, 'agent': agent_obj} dictsself.active_agents = []@@ -227,9 +164,6 @@ class SyncServer(LockingServer):# self.default_interface = default_interface# self.default_interface = default_interface_cls()- # The default persistence manager that will get assigned to agents ON CREATION- # self.default_persistence_manager_cls = default_persistence_manager_cls-# Initialize the connection to the DBtry:self.config = MemGPTConfig.load()@@ -251,27 +185,9 @@ class SyncServer(LockingServer):assert self.config.persona is not None, "Persona must be set in the config"assert self.config.human is not None, "Human must be set in the config"- # Update storage URI to match passed in settings- # (NOTE: no longer needed since envs being used, I think)- # for memory_type in ("archival", "recall", "metadata"):- # if settings.memgpt_pg_uri:- # # override with env- # setattr(self.config, f"{memory_type}_storage_uri", settings.memgpt_pg_uri)- # self.config.save()-# TODO figure out how to handle credentials for the serverself.credentials = MemGPTCredentials.load()- # Ensure valid database configuration- # TODO: add back once tests are matched- # assert (- # self.config.metadata_storage_type == "postgres"- # ), f"Invalid metadata_storage_type for server: {self.config.metadata_storage_type}"- # assert (- # self.config.archival_storage_type == "postgres"- # ), f"Invalid archival_storage_type for server: {self.config.archival_storage_type}"- # assert self.config.recall_storage_type == "postgres", f"Invalid recall_storage_type for server: {self.config.recall_storage_type}"-# Generate default LLM/Embedding configs for the server# TODO: we may also want to do the same thing with default persona/human/etc.self.server_llm_config = LLMConfig(@@ -280,11 +196,6 @@ class SyncServer(LockingServer):model_endpoint=self.config.default_llm_config.model_endpoint,model_wrapper=self.config.default_llm_config.model_wrapper,context_window=self.config.default_llm_config.context_window,- # openai_key=self.credentials.openai_key,- # azure_key=self.credentials.azure_key,- # azure_endpoint=self.credentials.azure_endpoint,- # azure_version=self.credentials.azure_version,- # azure_deployment=self.credentials.azure_deployment,)self.server_embedding_config = EmbeddingConfig(embedding_endpoint_type=self.config.default_embedding_config.embedding_endpoint_type,@@ -306,7 +217,6 @@ class SyncServer(LockingServer):"""Saves all the agents that are in the in-memory object store"""for agent_d in self.active_agents:try:- # agent_d["agent"].save()save_agent(agent_d["agent"], self.ms)logger.info(f"Saved agent {agent_d['agent_id']}")except Exception as e:@@ -324,7 +234,6 @@ class SyncServer(LockingServer):# Make sure the agent doesn't already existif self._get_agent(user_id=user_id, agent_id=agent_id) is not None:# Can be triggered on concucrent request, so don't throw a full error- # raise KeyError(f"Agent (user={user_id}, agent={agent_id}) is already loaded")logger.exception(f"Agent (user={user_id}, agent={agent_id}) is already loaded")return# Add Agent instance to the in-memory list@@ -579,7 +488,6 @@ class SyncServer(LockingServer):return usage- # @LockingServer.agent_lock_decoratordef user_message(self,user_id: str,@@ -629,7 +537,6 @@ class SyncServer(LockingServer):usage = self._step(user_id=user_id, agent_id=agent_id, input_message=packaged_user_message, timestamp=timestamp)return usage- # @LockingServer.agent_lock_decoratordef system_message(self,user_id: str,