Skip to content

Commit 434fa8a

Browse files
Update persona.clone() docstring
1 parent b042b5f commit 434fa8a

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/sdialog/personas.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,22 @@ class BasePersona(BaseModel, ABC):
7070

7171
def clone(self, new_id: int = None, **kwargs) -> "BasePersona":
7272
"""
73-
Creates a clone of the persona with optional overrides.
73+
Creates a deep copy of the persona, with optional attribute overrides.
7474
75+
The cloned persona will have all attributes copied from the original, with any provided keyword arguments
76+
(`kwargs`) used to override or update specific fields. The clone receives a new metadata object:
77+
78+
- The `parentId` field in the clone's metadata is set to the original persona's `id` (if present).
79+
- The `id` field in the clone's metadata is set to `new_id` if provided, otherwise to the original's `id`.
80+
- All other metadata fields are copied from the original.
81+
82+
This method is useful for generating variations of a persona for ablation, branching, or scenario testing
83+
without modifying the original instance. The clone is a fully independent object.
84+
85+
:param new_id: Optional new unique ID for the cloned persona.
86+
:type new_id: int, optional
7587
:param kwargs: Attributes to override in the cloned persona.
76-
:return: A new instance of the persona with updated attributes.
88+
:return: A new instance of the persona with updated attributes and metadata.
7789
:rtype: BasePersona
7890
"""
7991
data = self.json()

0 commit comments

Comments
 (0)