From ba8fbed30a467c58663ac72e97cb0328a18c40cb Mon Sep 17 00:00:00 2001 From: Brandon Hancock Date: Fri, 13 Sep 2024 12:47:43 -0400 Subject: [PATCH] More changes and todos --- src/crewai/crews/crew_output.py | 8 ++++++++ src/crewai/flow/flow.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/crewai/crews/crew_output.py b/src/crewai/crews/crew_output.py index 64d1f9caf..c9a92a0d0 100644 --- a/src/crewai/crews/crew_output.py +++ b/src/crewai/crews/crew_output.py @@ -41,6 +41,14 @@ class CrewOutput(BaseModel): output_dict.update(self.pydantic.model_dump()) return output_dict + def __getitem__(self, key): + if self.pydantic and hasattr(self.pydantic, key): + return getattr(self.pydantic, key) + elif self.json_dict and key in self.json_dict: + return self.json_dict[key] + else: + raise KeyError(f"Key '{key}' not found in CrewOutput.") + def __str__(self): if self.pydantic: return str(self.pydantic) diff --git a/src/crewai/flow/flow.py b/src/crewai/flow/flow.py index ed7b933d3..3fa91f31e 100644 --- a/src/crewai/flow/flow.py +++ b/src/crewai/flow/flow.py @@ -4,6 +4,8 @@ from typing import Any, Callable, Dict, Generic, List, Set, Type, TypeVar, Union from pydantic import BaseModel +# TODO: Allow people to pass results from one method to another and not just state + T = TypeVar("T", bound=Union[BaseModel, Dict[str, Any]])