Task Suite¶
TaskSuite
¶
TaskSuite(
name: str,
environment_type: type[Env],
tools: list[Function],
data_path: Path | None = None,
)
A suite of tasks that can be run in an environment. Tasks can be both user tasks and injection tasks. It is not mandatory to have injection tasks in case the suite is used to evaluate the model only for utility.
Parameters:
-
name
(str
) –The name of the suite.
-
environment_type
(type[Env]
) –The environment type that the suite operates on.
-
tools
(list[Function]
) –A list of tools that the agent can use to solve the tasks.
-
data_path
(Path | None
, default:None
) –The path to the suite data directory. It should be provided for non-default suites. The directory should contain the following files: -
environment.yaml
: The data of the environment. -injection_vectors.yaml
: The injection vectors in the environment.
Source code in src/agentdojo/task_suite/task_suite.py
98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
user_tasks
property
¶
user_tasks: dict[str, BaseUserTask[Env]]
The user tasks in the suite.
Returns:
-
dict[str, BaseUserTask[Env]]
–A dictionary of user tasks with their IDs as keys.
injection_tasks
property
¶
injection_tasks: dict[str, BaseInjectionTask[Env]]
The injection tasks in the suite.
Returns:
-
dict[str, BaseInjectionTask[Env]]
–A dictionary of injection tasks with their IDs as keys.
register_user_task
¶
register_user_task(
task: type[BaseUserTask[Env]],
) -> type[BaseUserTask[Env]]
Register a user task in the suite.
Parameters:
-
task
(type[BaseUserTask[Env]]
) –The user task class to register.
Source code in src/agentdojo/task_suite/task_suite.py
136 137 138 139 140 141 142 143 144 145 146 |
|
get_user_task_by_id
¶
get_user_task_by_id(task_id: str) -> BaseUserTask[Env]
Get a user task by its ID.
Source code in src/agentdojo/task_suite/task_suite.py
157 158 159 |
|
register_injection_task
¶
register_injection_task(
task: type[BaseInjectionTask[Env]],
) -> type[BaseInjectionTask[Env]]
Register an injection task in the suite.
Parameters:
-
task
(type[BaseInjectionTask[Env]]
) –The injection task class to register.
Source code in src/agentdojo/task_suite/task_suite.py
161 162 163 164 165 166 167 168 169 170 171 |
|
get_injection_task_by_id
¶
get_injection_task_by_id(
injection_task_id: str,
) -> BaseInjectionTask[Env]
Get an injection task by its ID.
Source code in src/agentdojo/task_suite/task_suite.py
182 183 184 |
|
run_task_with_pipeline
¶
run_task_with_pipeline(
agent_pipeline: BasePipelineElement,
user_task: BaseUserTask[Env] | BaseInjectionTask[Env],
injection_task: BaseInjectionTask[Env] | None,
injections: dict[str, str],
runtime_class: type[
FunctionsRuntime
] = FunctionsRuntime,
environment: Env | None = None,
verbose: bool = False,
) -> tuple[bool, bool]
Run a task with the provided pipeline.
Parameters:
-
agent_pipeline
(BasePipelineElement
) –The pipeline to use for the task.
-
user_task
(BaseUserTask[Env] | BaseInjectionTask[Env]
) –The user task to run.
-
injection_task
(BaseInjectionTask[Env] | None
) –The injection task to run.
-
injections
(dict[str, str]
) –The injections to use for the task.
-
runtime_class
(type[FunctionsRuntime]
, default:FunctionsRuntime
) –The runtime class to use for the task.
-
environment
(Env | None
, default:None
) –The environment to use for the task.
-
verbose
(bool
, default:False
) –Whether to print debug information.
Returns:
-
bool
–A tuple of two booleans, the first indicating whether the task was successful, and the second indicating if
-
bool
–the injection was successful.
Source code in src/agentdojo/task_suite/task_suite.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|