Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: remove usage of `anon_clientid` and migrate to `DEFAULT_USER` (#1805)
Sarah Wooders9f9e967c8bdf
diff --git a/letta/cli/cli.py b/letta/cli/cli.pyindex ae038b566..c8c292162 100644--- a/letta/cli/cli.py+++ b/letta/cli/cli.py@@ -464,7 +464,6 @@ def run(# read user id from configms = MetadataStore(config)client = create_client()- client.user_id# determine agent to use, if not providedif not yes and not agent:diff --git a/letta/cli/cli_load.py b/letta/cli/cli_load.pyindex 92a11b2fb..eaef8d697 100644--- a/letta/cli/cli_load.py+++ b/letta/cli/cli_load.py@@ -18,56 +18,6 @@ from letta.data_sources.connectors import DirectoryConnectorapp = typer.Typer()-# NOTE: not supported due to llama-index breaking things (please reach out if you still need it)-# @app.command("index")-# def load_index(-# name: Annotated[str, typer.Option(help="Name of dataset to load.")],-# dir: Annotated[Optional[str], typer.Option(help="Path to directory containing index.")] = None,-# user_id: Annotated[Optional[uuid.UUID], typer.Option(help="User ID to associate with dataset.")] = None,-# ):-# """Load a LlamaIndex saved VectorIndex into Letta"""-# if user_id is None:-# config = LettaConfig.load()-# user_id = uuid.UUID(config.anon_clientid)-#-# try:-# # load index data-# storage_context = StorageContext.from_defaults(persist_dir=dir)-# loaded_index = load_index_from_storage(storage_context)-#-# # hacky code to extract out passages/embeddings (thanks a lot, llama index)-# embed_dict = loaded_index._vector_store._data.embedding_dict-# node_dict = loaded_index._docstore.docs-#-# # create storage connector-# config = LettaConfig.load()-# if user_id is None:-# user_id = uuid.UUID(config.anon_clientid)-#-# passages = []-# for node_id, node in node_dict.items():-# vector = embed_dict[node_id]-# node.embedding = vector-# # assume embedding are the same as config-# passages.append(-# Passage(-# text=node.text,-# embedding=np.array(vector),-# embedding_dim=config.default_embedding_config.embedding_dim,-# embedding_model=config.default_embedding_config.embedding_model,-# )-# )-# assert config.default_embedding_config.embedding_dim == len(-# vector-# ), f"Expected embedding dimension {config.default_embedding_config.embedding_dim}, got {len(vector)}"-#-# if len(passages) == 0:-# raise ValueError(f"No passages found in index {dir}")-#-# insert_passages_into_source(passages, name, user_id, config)-# except ValueError as e:-# typer.secho(f"Failed to load index from provided information.\n{e}", fg=typer.colors.RED)-default_extensions = ".txt,.md,.pdf"diff --git a/letta/config.py b/letta/config.pyindex 6a582a964..57a42d682 100644--- a/letta/config.py+++ b/letta/config.py@@ -2,7 +2,6 @@ import configparserimport inspectimport jsonimport os-import uuidfrom dataclasses import dataclassfrom typing import Optional@@ -14,6 +13,7 @@ from letta.constants import (DEFAULT_HUMAN,DEFAULT_PERSONA,DEFAULT_PRESET,+ DEFAULT_USER_ID,LETTA_DIR,)from letta.log import get_logger@@ -45,7 +45,7 @@ def set_field(config, section, field, value):@dataclassclass LettaConfig:config_path: str = os.getenv("MEMGPT_CONFIG_PATH") or os.path.join(LETTA_DIR, "config")- anon_clientid: str = str(uuid.UUID(int=0))+ anon_clientid: str = DEFAULT_USER_ID# presetpreset: str = DEFAULT_PRESET # TODO: rename to system prompt@@ -100,10 +100,6 @@ class LettaConfig:# self.context_window = int(self.context_window)pass- @staticmethod- def generate_uuid() -> str:- return uuid.UUID(int=uuid.getnode()).hex-@classmethoddef load(cls, llm_config: Optional[LLMConfig] = None, embedding_config: Optional[EmbeddingConfig] = None) -> "LettaConfig":# avoid circular import@@ -199,8 +195,7 @@ class LettaConfig:# assert llm_config is not None, "LLM config must be provided if config does not exist"# create new config- anon_clientid = LettaConfig.generate_uuid()- config = cls(anon_clientid=anon_clientid, config_path=config_path)+ config = cls(config_path=config_path)config.create_config_dir() # create dirs@@ -284,8 +279,6 @@ class LettaConfig:set_field(config, "version", "letta_version", letta.__version__)# client- if not self.anon_clientid:- self.anon_clientid = self.generate_uuid()set_field(config, "client", "anon_clientid", self.anon_clientid)# always make sure all directories are presentdiff --git a/letta/server/server.py b/letta/server/server.pyindex 6fdcff99a..80b4c4f17 100644--- a/letta/server/server.py+++ b/letta/server/server.py@@ -1441,10 +1441,6 @@ class SyncServer(Server):logger.exception(f"Failed to delete agent {agent_id} via ID with:\n{str(e)}")raise ValueError(f"Failed to delete agent {agent_id} in database")- def authenticate_user(self) -> str:- # TODO: Implement actual authentication to enable multi user setup- return str(LettaConfig.load().anon_clientid)-def api_key_to_user(self, api_key: str) -> str:"""Decode an API key to a user"""user = self.ms.get_user_from_api_key(api_key=api_key)@@ -1973,19 +1969,6 @@ class SyncServer(Server):return current_userreturn self.get_default_user()- ## NOTE: same code as local client to get the default user- # config = LettaConfig.load()- # user_id = config.anon_clientid- # user = self.get_user(user_id)-- # if not user:- # user = self.create_user(UserCreate())-- # # # update config- # config.anon_clientid = str(user.id)- # config.save()-- # return userdef list_models(self) -> List[LLMConfig]:"""List available models"""