MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / create_block

Method create_block

methods/letta/client/client.py:1081–1096  ·  view source on GitHub ↗
(
        self, label: str, value: str, limit: Optional[int] = None, template_name: Optional[str] = None, is_template: bool = False
    )

Source from the content-addressed store, hash-verified

1079 return [Block(**block) for block in response.json()]
1080
1081 def create_block(
1082 self, label: str, value: str, limit: Optional[int] = None, template_name: Optional[str] = None, is_template: bool = False
1083 ) -> Block: #
1084 request_kwargs = dict(label=label, value=value, template=is_template, template_name=template_name)
1085 if limit:
1086 request_kwargs["limit"] = limit
1087 request = CreateBlock(**request_kwargs)
1088 response = requests.post(f"{self.base_url}/{self.api_prefix}/blocks", json=request.model_dump(), headers=self.headers)
1089 if response.status_code != 200:
1090 raise ValueError(f"Failed to create block: {response.text}")
1091 if request.label == "human":
1092 return Human(**response.json())
1093 elif request.label == "persona":
1094 return Persona(**response.json())
1095 else:
1096 return Block(**response.json())
1097
1098 def update_block(self, block_id: str, name: Optional[str] = None, text: Optional[str] = None, limit: Optional[int] = None) -> Block:
1099 request = BlockUpdate(id=block_id, template_name=name, value=text, limit=limit if limit else self.get_block(block_id).limit)

Callers 5

create_agentMethod · 0.95
create_humanMethod · 0.95
create_personaMethod · 0.95
rethink_memoryFunction · 0.45
memory_rethinkFunction · 0.45

Calls 7

CreateBlockClass · 0.90
HumanClass · 0.90
PersonaClass · 0.90
BlockClass · 0.90
postMethod · 0.80
model_dumpMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected