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:
lorenzejay
2025-10-15 13:22:28 -07:00
parent c0e49e8d3b
commit 636584acf1

View File

@@ -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