create_trait()
Create a trait definition programmatically.
Usage
create_trait(
name,
*,
display_name="",
category="custom",
description="",
constraints=None,
critical_constraints=None,
expertise_extra="",
avoid_topics=None,
tools=None,
tags=None,
temperature=None,
task_context_extra="",
output_format=None,
final_emphasis="",
metadata=None
)Parameters
name: str-
Machine-readable identifier (e.g.,
"security_focused"). display_name: str = ""-
Human-readable label. Defaults to name title-cased.
category: str = "custom"-
Grouping category. Defaults to
"custom". description: str = ""-
One-line description of what this trait adds.
constraints: list[str] | None = None-
Constraints to append to a persona.
critical_constraints: list[str] | None = None-
Critical constraints to append.
expertise_extra: str = ""-
Text appended to a persona’s expertise.
avoid_topics: list[str] | None = None-
Topics to add to a persona’s avoid list.
tools: list[str] | None = None-
Tool names to add.
tags: list[str] | None = None-
Tags to add.
temperature: float | None = None-
Temperature override (applied when the trait is applied).
task_context_extra: str = ""-
Text appended to a persona’s task context.
output_format: list[str] | None = None-
Output format directives to append.
final_emphasis: str = ""-
Replaces a persona’s final emphasis when the trait is applied.
metadata: dict[str, Any] | None = None- Arbitrary metadata.
Returns
TraitDefinition- A new trait definition.
Examples
import talk_box as tb
friendly = tb.create_trait(
"junior_friendly",
description="Adjusts output for beginners.",
constraints=["Explain jargon when first used"],
)