mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 09:08:31 +00:00
Refactor Task Class Guardrail Type Annotation
- Updated the type annotation for the `guardrails` field in the Task class from `list` to `Sequence` to enhance type safety and compatibility with various sequence types. - This change improves type checking and aligns with best practices for handling callable functions and string descriptions in guardrail validation. This update contributes to the overall robustness and maintainability of the Task class.
This commit is contained in:
@@ -5,7 +5,7 @@ import logging
|
||||
import threading
|
||||
import uuid
|
||||
import warnings
|
||||
from collections.abc import Callable
|
||||
from collections.abc import Callable, Sequence
|
||||
from concurrent.futures import Future
|
||||
from copy import copy as shallow_copy
|
||||
from hashlib import md5
|
||||
@@ -153,7 +153,7 @@ class Task(BaseModel):
|
||||
description="Function or string description of a guardrail to validate task output before proceeding to next task",
|
||||
)
|
||||
guardrails: (
|
||||
list[Callable[[TaskOutput], tuple[bool, Any]] | str]
|
||||
Sequence[Callable[[TaskOutput], tuple[bool, Any]] | str]
|
||||
| Callable[[TaskOutput], tuple[bool, Any]]
|
||||
| str
|
||||
| None
|
||||
|
||||
Reference in New Issue
Block a user