Creating Variants
Basic Usage
Create a variant by instantiating theVariant class with a base model:
Adding features to a variant
Conditional Controls
You can create variants that respond dynamically to feature activations:Methods
set()
Set feature modifications. This method is overloaded to handle different input types. Signatures:Feature | FeatureGroup
Single feature or feature group to modify. Required when using the first signature.
float
Modification value (typically between -1 and 1). Required when using the first signature.
dict[Feature, float] | FeatureEdits
Dictionary of features and their values, or a FeatureEdits object. Required when using the second signature.
set_when()
Define conditional feature modifications. Parameters:ConditionalGroup
required
Condition that triggers the modifications
dict[Feature, float] | FeatureEdits
required
Feature modifications to apply when condition is met
set_when example
abort_when()
Abort generation when a condition is met. Parameters:ConditionalGroup
required
Condition that triggers the abort
Abort example
reset()
Remove all feature modifications. Example:Reset variant
clear()
Remove modifications for specific features. Parameters:Feature | FeatureGroup
required
Feature(s) to clear modifications for
Clear particular feature
Serialization
Variants can be serialized to and from JSON:Storing and loading variants
Using with OpenAI SDK
Variants are compatible with the OpenAI SDK:Using with OpenAI SDK
Classes
VariantMetaData
Metadata about a model variant. Properties:str
Name of the variant
str
Base model identifier
str
Unique identifier for the variant