Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: enhance RESTClient to support optional token and password for authorization
Theo Conrads45b9efbce20c
diff --git a/letta/client/client.py b/letta/client/client.pyindex a3f0f256b..3e46d16ff 100644--- a/letta/client/client.py+++ b/letta/client/client.py@@ -408,7 +408,8 @@ class RESTClient(AbstractClient):def __init__(self,base_url: str,- token: str,+ token: Optional[str] = None,+ password: Optional[str] = None,api_prefix: str = "v1",debug: bool = False,default_llm_config: Optional[LLMConfig] = None,@@ -424,11 +425,18 @@ class RESTClient(AbstractClient):default_llm_config (Optional[LLMConfig]): The default LLM configuration.default_embedding_config (Optional[EmbeddingConfig]): The default embedding configuration.headers (Optional[Dict]): The additional headers for the REST API.+ token (Optional[str]): The token for the REST API when using managed letta service.+ password (Optional[str]): The password for the REST API when using self hosted letta service."""super().__init__(debug=debug)self.base_url = base_urlself.api_prefix = api_prefix- self.headers = {"accept": "application/json", "X-BARE-PASSWORD": f"password {token}"}+ if token:+ self.headers = {"accept": "application/json", "Authorization": f"Bearer {token}"}+ elif password:+ self.headers = {"accept": "application/json", "X-BARE-PASSWORD": f"password {password}"}+ else:+ raise ValueError("Either token or password must be provided")if headers:self.headers.update(headers)self._default_llm_config = default_llm_config