Files
crewAI/src/crewai/utilities/formatter.py
Greyson LaLonde 3e97393f58 chore: improve typing and consolidate utilities
- add type annotations across utility modules  
- refactor printer system, agent utils, and imports for consistency  
- remove unused modules, constants, and redundant patterns  
- improve runtime type checks, exception handling, and guardrail validation  
- standardize warning suppression and logging utilities  
- fix llm typing, threading/typing edge cases, and test behavior
2025-09-23 11:33:46 -04:00

45 lines
1.1 KiB
Python

from __future__ import annotations
from typing import TYPE_CHECKING, Final
from crewai.utilities.constants import _NotSpecified
if TYPE_CHECKING:
from crewai.task import Task
from crewai.tasks.task_output import TaskOutput
DIVIDERS: Final[str] = "\n\n----------\n\n"
def aggregate_raw_outputs_from_task_outputs(task_outputs: list[TaskOutput]) -> str:
"""Generate string context from the task outputs.
Args:
task_outputs: List of TaskOutput objects.
Returns:
A string containing the aggregated raw outputs from the task outputs.
"""
return DIVIDERS.join(output.raw for output in task_outputs)
def aggregate_raw_outputs_from_tasks(tasks: list[Task] | _NotSpecified) -> str:
"""Generate string context from the tasks.
Args:
tasks: List of Task objects or _NotSpecified.
Returns:
A string containing the aggregated raw outputs from the tasks.
"""
task_outputs = (
[task.output for task in tasks if task.output is not None]
if isinstance(tasks, list)
else []
)
return aggregate_raw_outputs_from_task_outputs(task_outputs)