More changes and todos

This commit is contained in:
Brandon Hancock
2024-09-13 12:47:43 -04:00
parent abfd121f99
commit ba8fbed30a
2 changed files with 10 additions and 0 deletions

View File

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

View File

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