fix: Remove protected 'name' attribute from entity type models

Pydantic BaseModel reserves 'name' as a protected attribute. Removed
the 'name' attribute from dynamically created entity type models as
it's not needed - the entity type name is already stored as the class
name and dict key.

Fixed error: name cannot be used as an attribute for Requirement as
it is a protected attribute name.
This commit is contained in:
Daniel Chalef 2025-10-29 22:58:56 -07:00
parent ca929c5604
commit 8c02683174

View file

@ -154,11 +154,11 @@ class GraphitiService:
custom_types = {}
for entity_type in self.config.graphiti.entity_types:
# Create a dynamic Pydantic model for each entity type
# Note: Don't use 'name' as it's a protected Pydantic attribute
entity_model = type(
entity_type.name,
(BaseModel,),
{
'__annotations__': {'name': str},
'__doc__': entity_type.description,
},
)