TaskConfig
conatus.tasks.config.ConsolidatedTaskConfig
dataclass
¶
ConsolidatedTaskConfig(
user_provided_config: TaskConfig | None = None,
)
The configuration for a task, consolidated with defaults.
The user can provide a TaskConfig
dictionary when instantiating a Task. This
class consolidates the user-provided values with the default values.
Hierarchy of configuration values¶
The hierarchy of configuration values is as follows (higher values override lower values):
- User-provided values.
- Defaults defined in the
Taskclass. - Defaults defined in the
Agentclass. - Defaults defined in the
AIInterfaceclass. - System-defined defaults.
This hierarchy is used to determine the value of a configuration attribute.
How we handle the hierarchy¶
This class contains the system default values for all configuration attributes. When the user provides a configuration dictionary, we consolidate the user-provided values with the default values.
Crucially, this class keeps track of what the user actually provided. This
means that, as it is passed from Task to
AIInterface,
the classes can send their defaults, and they will be properly handled:
they will not override the user-provided values if the user has set
them; but if the user hasn't, then the values will override the system
defaults.
How to use this class¶
This class is instantiated with a TaskConfig
dictionary. This dictionary is then
passed to the constructor of the Task
class.
After that's done, you can use the instance of this class like a normal dataclass, and the confidence that you will get correctly typed values.
Classes should use the add_default_values method to add the default
values to the class:
from conatus.tasks.config import ConsolidatedTaskConfig
class MyClass:
# Imagine you want to add the default value for the preferred_model
# attribute, but only set it if the user (or a class up the hierarchy)
# hasn't provided a value.
preferred_model: str = "openai:gpt-4o"
config: ConsolidatedTaskConfig
def __init__(self, config: ConsolidatedTaskConfig) -> None:
self.config = config.add_default_values(
preferred_model=self.preferred_model,
)
Initialize the configuration with the user-provided values.
| PARAMETER | DESCRIPTION |
|---|---|
user_provided_config
|
The user-provided configuration.
TYPE:
|
Source code in conatus/tasks/config.py
max_var_repr_len
class-attribute
instance-attribute
¶
max_var_repr_len: int | None = (
DEFAULT_MAX_STR_REPR_LEN_PER_VARIABLE
)
The maximum length of the string representation of a variable.
For more information, see TaskConfig.max_var_repr_len
.
Default value: 300.
max_result_repr_len
class-attribute
instance-attribute
¶
max_result_repr_len: int | None = (
DEFAULT_MAX_RESULT_REPR_LEN
)
The maximum length of the string representation of a result.
For more information, see TaskConfig.max_result_repr_len
.
Default value: 2000.
preferred_provider
class-attribute
instance-attribute
¶
preferred_provider: ProviderName | str = 'openai'
The preferred AI provider to use, if any.
For more information, see TaskConfig.preferred_provider
.
preferred_model
class-attribute
instance-attribute
¶
preferred_model: BaseAIModel | ModelName | str = (
"openai:gpt-4o"
)
The default model to use, if any.
For more information, see TaskConfig.preferred_model
.
stream
class-attribute
instance-attribute
¶
stream: bool = True
Whether to stream the response or not.
For more information, see [TaskConfig.stream
max_turns
class-attribute
instance-attribute
¶
max_turns: int = 20
The maximum number of turns to run.
For more information, see TaskConfig.max_turns
.
user_provided
instance-attribute
¶
user_provided: TaskConfig = user_provided_config
Attributes provided by the user, at the top of the hierarchy.
class_provided
instance-attribute
¶
Attributes provided by the various classes in the hierarchy.
This is a list of dictionaries, where each dictionary is the configuration for a class in the hierarchy.
add_default_values
¶
add_default_values(**kwargs: ParamType) -> None
Add default values to the configuration.
Pass new default values to the configuration. These values will be added at the lowest level of the hierarchy.
| PARAMETER | DESCRIPTION |
|---|---|
kwargs
|
The new default values to add to the configuration.
TYPE:
|