feat: remove organization from tool pydantic schema (#3430)

This commit is contained in:
cthomas
2025-07-20 00:00:31 -07:00
committed by GitHub
parent 555db59f2c
commit 2b0dc4a1f9
4 changed files with 29 additions and 10 deletions

View File

@@ -1,3 +1,7 @@
from typing import Dict
from marshmallow import post_dump, pre_load
from letta.orm import Tool
from letta.schemas.tool import Tool as PydanticTool
from letta.serialize_schemas.marshmallow_base import BaseSchema
@@ -10,6 +14,24 @@ class SerializedToolSchema(BaseSchema):
__pydantic_model__ = PydanticTool
@post_dump
def sanitize_ids(self, data: Dict, **kwargs) -> Dict:
# delete id
del data["id"]
del data["_created_by_id"]
del data["_last_updated_by_id"]
return data
@pre_load
def regenerate_ids(self, data: Dict, **kwargs) -> Dict:
if self.Meta.model:
data["id"] = self.generate_id()
data["_created_by_id"] = self.actor.id
data["_last_updated_by_id"] = self.actor.id
return data
class Meta(BaseSchema.Meta):
model = Tool
exclude = BaseSchema.Meta.exclude + ("is_deleted",)
exclude = BaseSchema.Meta.exclude + ("is_deleted", "organization")