From 5a13bba29585891422c9a60c93f287a5539e1c39 Mon Sep 17 00:00:00 2001 From: Jyotirmaya Mahanta Date: Thu, 9 Jan 2025 04:16:05 +0530 Subject: [PATCH] fix: validate after limit assignment in `create_block` (#2310) --- letta/client/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/letta/client/client.py b/letta/client/client.py index ae75e9eb1b..6795878cfb 100644 --- a/letta/client/client.py +++ b/letta/client/client.py @@ -1031,9 +1031,10 @@ def list_blocks(self, label: Optional[str] = None, templates_only: Optional[bool def create_block( self, label: str, value: str, limit: Optional[int] = None, template_name: Optional[str] = None, is_template: bool = False ) -> Block: # - request = CreateBlock(label=label, value=value, template=is_template, template_name=template_name) + request_kwargs = dict(label=label, value=value, template=is_template, template_name=template_name) if limit: - request.limit = limit + request_kwargs['limit'] = limit + request = CreateBlock(**request_kwargs) response = requests.post(f"{self.base_url}/{self.api_prefix}/blocks", json=request.model_dump(), headers=self.headers) if response.status_code != 200: raise ValueError(f"Failed to create block: {response.text}")