fabricatio_capabilities.capabilities.task

A module for the task capabilities of the Fabricatio library.

Classes

ProposeTask

A class that proposes a task based on a prompt.

DispatchTask

A class that dispatches a task based on a task object.

Module Contents

class fabricatio_capabilities.capabilities.task.ProposeTask(/, **data: Any)

Bases: fabricatio_core.capabilities.propose.Propose, abc.ABC

A class that proposes a task based on a prompt.

async propose_task[T](prompt: str, **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[fabricatio_core.Task[T]]]) fabricatio_core.Task[T] | None

Asynchronously proposes a task based on a given prompt and parameters.

Parameters:
  • prompt – The prompt text for proposing a task, which is a string that must be provided.

  • **kwargs – The keyword arguments for the LLM (Large Language Model) usage.

Returns:

A Task object based on the proposal result.

class fabricatio_capabilities.capabilities.task.DispatchTask(/, **data: Any)

Bases: fabricatio_core.capabilities.usages.UseLLM, abc.ABC

A class that dispatches a task based on a task object.

async dispatch_task[T](task: fabricatio_core.Task[T], candidates: Set[fabricatio_core.models.role.Role], **kwargs: Unpack[fabricatio_core.models.kwargs_types.ValidateKwargs[str]]) T | None

Asynchronously dispatches a task to an appropriate delegate based on candidate selection.

This method uses a template to render instructions for selecting the most suitable candidate, then delegates the task to that selected candidate by resolving its namespace.

Parameters:
  • task – The task object to be dispatched. It must support delegation.

  • candidates – A mapping of identifiers to WithBriefing instances representing available delegates. Each key is a unique identifier and the corresponding value contains briefing details.

  • **kwargs – Keyword arguments unpacked from ChooseKwargs, typically used for LLM configuration.

Returns:

The result of the delegated task execution, which is of generic type T.

Raises:
  • ValueError – If no valid target is picked or if delegation fails.

  • KeyError – If the selected target does not exist in the reverse mapping.