TaskDefinition
conatus.tasks.definition
¶
BaseTask information.
TaskDefinition
dataclass
¶
TaskDefinition(
name: str,
user_prompt: str,
actions: OrderedDict[str, Action],
user_provided_actions_keys: list[str],
inputs_with_positions: OrderedDict[
str, tuple[TypeOfType, ParamKind, bool, str]
],
inputs_form: ExpectedInputForm | None,
inputs_are_predefined: bool,
predefined_inputs: (
OrderedDict[str, RuntimeVariable] | None
),
outputs_with_positions: OrderedDict[
str, tuple[TypeOfType, str]
],
outputs_form: ExpectedOutputForm | None,
flatten_output_to_string: bool = False,
)
Definition of a BaseTask.
Note that this information is invariant across runs. This means, in
practice, that inputs and outputs are types, not values, because
they describe the expected inputs and outputs of the task, not the actual
inputs and outputs of the task.
user_prompt
instance-attribute
¶
user_prompt: str
The user prompt of the task, as passed in the constructor.
actions
instance-attribute
¶
actions: OrderedDict[str, Action]
The actions that can be used to perform the task.
user_provided_actions_keys
instance-attribute
¶
The keys of the actions provided by the user in the constructor.
This is essentially actions.keys(), minus:
* any actions already included by the Task
subclass, or
* any standard library actions such as terminate
.
Use the user_provided_actions
property to get the actions as an OrderedDict.
inputs_with_positions
instance-attribute
¶
inputs_with_positions: OrderedDict[
str, tuple[TypeOfType, ParamKind, bool, str]
]
The input specifications of the task.
We say "with positions" because the inputs are stored in an OrderedDict.
The structure of the dictionary is as follows:
WhereParamKind
is the kind of the input, input_type is the type of the input, and
is_required is a boolean indicating whether the input is required.
inputs_form
instance-attribute
¶
inputs_form: ExpectedInputForm | None
The form of the inputs of the agent.
Users can define the expected inputs in four ways:
"none": no inputs are expected."singleton": a single input is expected."list": a list of inputs is expected."dict": a dictionary of inputs is expected.
Internally, we use this parameter to see how we parse inputs when they are given by the user during a run.
Note that in the case where the task comes from a decorator, this
parameter is set to None, since we can have both positional and
keyword inputs.
predefined_inputs
instance-attribute
¶
predefined_inputs: OrderedDict[str, RuntimeVariable] | None
The predefined inputs (a.k.a. starting variables) of the agent.
These are the inputs that are provided in the starting_variables
parameter of the constructor of the BaseTask
subclass.
If the inputs are not predefined, this is set to None.
outputs_with_positions
instance-attribute
¶
outputs_with_positions: OrderedDict[
str, tuple[TypeOfType, str]
]
The outputs of the task.
We say "with positions" because the outputs are stored in an OrderedDict.
These are the outputs that are expected by the task, as passed in the constructor. We store the type of the output and the description of the output.
outputs_form
instance-attribute
¶
outputs_form: ExpectedOutputForm | None
The form of the outputs of the agent.
Users can define the expected outputs in four ways:
"none": no outputs are expected, the agent should decide what to return."singleton": a single output is expected."list": a list of outputs is expected."dict": a dictionary of outputs is expected.
Internally, we use this parameter to see how we parse outputs when they are given by the agent during a run.
Note that in the case where the task comes from a decorator, this
parameter is set to None, since we can have both positional and
keyword outputs.
flatten_output_to_string
class-attribute
instance-attribute
¶
flatten_output_to_string: bool = False
Whether to flatten the output to a string.
This is set to True if the user initializes an agent without decorating
a function, and does not specify the outputs parameter in the
constructor.
user_provided_actions
property
¶
user_provided_actions: OrderedDict[str, Action]
The actions provided by the user.
task_provided_actions
property
¶
task_provided_actions: OrderedDict[str, Action]
The actions provided by the task or the standard library.
UninitializedTaskArguments
dataclass
¶
UninitializedTaskArguments(
actions: (
Sequence[RawAction] | ActionStarterPack | None
) = None,
config: TaskConfig | None = None,
model_config: ModelConfig | SimpleDict | None = None,
agent_cls: type[BaseAgent] | None = None,
)
A data structure to store task decorator arguments.
If a function is decorated with @Task(actions=...), two operations needs
to happen:
- We create an instance of
BaseTask. - Immediately afterwards, that instance is called with the decorated function as the argument.
We need to be able to store the arguments passed to the decorator so that we can use them to initialize the task.
conatus.tasks._types.ExpectedInputForm
module-attribute
¶
The form of the inputs of the agent.
Can be "none", "singleton", "list", or "dict".
conatus.tasks._types.ExpectedOutputForm
module-attribute
¶
ExpectedOutputForm: TypeAlias = ExpectedInputForm
The form of the outputs of the agent.
Can be "none", "singleton", "list", or "dict".