Skip to content

Models

Entity

Bases: Object

Base model for entities with a unique identifier.

Source code in templates/models.py
24
25
26
27
28
29
30
31
32
class Entity(Object):
    """Base model for entities with a unique identifier."""

    id: str = Field(
        description="Unique identifier for the entity.",
        default_factory=lambda: str(uuid4()),
        min_length=1,
        max_length=50,
    )

Object

Bases: BaseModel

Base model for all data objects with common configuration and helper methods.

Source code in templates/models.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
class Object(BaseModel, populate_by_name=True, alias_generator=to_camel, from_attributes=True):
    """Base model for all data objects with common configuration and helper methods."""

    def dump(self, **kwargs: Any) -> dict[str, Any]:
        """Dump the model to a dictionary with default settings (camelCase, exclude None)."""
        kwargs.setdefault("by_alias", True)
        kwargs.setdefault("exclude_none", True)
        return self.model_dump(**kwargs)

    def dump_json(self, **kwargs: Any) -> str:
        """Dump the model to a JSON string with default settings (camelCase, exclude None)."""
        kwargs.setdefault("by_alias", True)
        kwargs.setdefault("exclude_none", True)
        return self.model_dump_json(**kwargs)

dump(**kwargs)

Dump the model to a dictionary with default settings (camelCase, exclude None).

Source code in templates/models.py
11
12
13
14
15
def dump(self, **kwargs: Any) -> dict[str, Any]:
    """Dump the model to a dictionary with default settings (camelCase, exclude None)."""
    kwargs.setdefault("by_alias", True)
    kwargs.setdefault("exclude_none", True)
    return self.model_dump(**kwargs)

dump_json(**kwargs)

Dump the model to a JSON string with default settings (camelCase, exclude None).

Source code in templates/models.py
17
18
19
20
21
def dump_json(self, **kwargs: Any) -> str:
    """Dump the model to a JSON string with default settings (camelCase, exclude None)."""
    kwargs.setdefault("by_alias", True)
    kwargs.setdefault("exclude_none", True)
    return self.model_dump_json(**kwargs)