TaskValidationMode
validate_task_content
- content (str): The task content or result to validate.
- task_id (str): Task ID for logging purposes. (default: :obj:
"unknown") - min_length (int): Minimum content length after stripping whitespace. (default: :obj:
1) - mode (TaskValidationMode): Validation mode - INPUT for task content, OUTPUT for task results. (default: :obj:
TaskValidationMode.INPUT) - check_failure_patterns (bool): Whether to check for failure indicators in the content. Only effective in OUTPUT mode. (default: :obj:
True)
is_task_result_insufficient
- task (Task): The task to check.
parse_response
- response (str): The model response.
- task_id (str, optional): a parent task id, the default value is “0”
Task instance.
TaskState
states
Task
- content (str): string content for task.
- id (str): An unique string identifier for the task. This should ideally be provided by the provider/model which created the task. (default: :obj:
uuid.uuid4()) - state (TaskState): The state which should be OPEN, RUNNING, DONE or DELETED. (default: :obj:
TaskState.FAILED) - type (Optional[str]): task type. (default: :obj:
None) - parent (Optional[Task]): The parent task, None for root task. (default: :obj:
None) - subtasks (List[Task]): The childrent sub-tasks for the task. (default: :obj:
[]) - result (Optional[str]): The answer for the task. (default: :obj:
"") - failure_count (int): The failure count for the task. (default: :obj:
0) - assigned_worker_id (Optional[str]): The ID of the worker assigned to this task. (default: :obj:
None) - dependencies (List[Task]): The dependencies for the task. (default: :obj:
[]) - additional_info (Optional[Dict[str, Any]]): Additional information for the task. (default: :obj:
None) - image_list (Optional[List[Union[Image.Image, str]]]): Optional list of PIL Image objects or image URLs (strings) associated with the task. (default: :obj:
None) - image_detail (
Literal["auto", "low", "high"]): Detail level of the images associated with the task. (default: :obj:auto) - video_bytes (Optional[bytes]): Optional bytes of a video associated with the task. (default: :obj:
None) - video_detail (
Literal["auto", "low", "high"]): Detail level of the videos associated with the task. (default: :obj:auto)
repr
from_message
- message (BaseMessage): The message to the task.
to_message
reset
update_result
- result (str): The task result.
set_id
- id (str): The id of the task.
set_state
- state (TaskState): The giving state.
add_subtask
- task (Task): The subtask to be added.
remove_subtask
- id (str): The id of the subtask to be removed.
get_running_task
to_string
- indent (str): The ident for hierarchical tasks.
- state (bool): Include or not task state.
get_result
- indent (str): The ident for hierarchical tasks.
decompose
- agent (ChatAgent): An agent that used to decompose the task.
- prompt (str, optional): A prompt to decompose the task. If not provided, the default prompt will be used.
- task_parser (Callable[[str, str], List[Task]], optional): A function to extract Task from response. If not provided, the default parse_response will be used.
_decompose_streaming
- response: Streaming response from agent
- task_parser: Function to parse tasks from response
- Yields: List[Task]: New tasks as they are parsed from streaming response
_decompose_non_streaming
- response: Regular response from agent
- task_parser: Function to parse tasks from response
_parse_partial_tasks
- response: Partial response content
<task>``</task> blocks
compose
- agent (ChatAgent): An agent that used to compose the task result.
- template (TextPrompt, optional): The prompt template to compose task. If not provided, the default template will be used.
- result_parser (Callable[[str, str], List[Task]], optional): A function to extract Task from response.
get_depth
TaskManager
- task (Task): The root Task.
init
gen_task_id
exist
current_task
topological_sort
- tasks (List[Task]): The giving list of tasks.
set_tasks_dependence
serial : root -> other1 -> other2
parallel: root -> other1
-> other2
Parameters:
- root (Task): A root task.
- others (List[Task]): A list of tasks.
add_tasks
evolve
- task (Task): A given task.
- agent (ChatAgent): An agent that used to evolve the task.
- template (TextPrompt, optional): A prompt template to evolve task. If not provided, the default template will be used.
- task_parser (Callable, optional): A function to extract Task from response. If not provided, the default parser will be used.
Task instance or None.