griptape
griptape copied to clipboard
Add `RunnableMixin` for pre/post processing on arbitrary run execution
- [x] I have read and agree to the contributing guidelines.
Is your feature request related to a problem? Please describe. there is a lot of different areas of the framework that could benefit from pre/post processing hooks on data.
Describe the solution you'd like
implement a RunnableMixin:
class RunnableMixin:
process_before_run_fn: Callable[[Any], Any]
process_after_run_fn: Callable[[Any], Any]
def before_run(self, *args, **kwargs) -> None (or Any?): ....
def run(self, *args, **kwargs) -> Any: ...
def after_run(self, *args, **kwargs) -> None (or Any?): ...
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
I'd like to hear more about what kind of pre/post processing you're envisioning. Is it mostly for data coercion of LLM output?
I'd like to hear more about what kind of pre/post processing you're envisioning. Is it mostly for data coercion of LLM output?
Mostly just getting the output into a format that is either a more specific type of artifact, or a different Python type.
As an example, I have a basic PromptTask that I am asking the LLM "respond with only true or false". I want to parse the output into a BooleanArtifact right on the task, so on the next task I can be confident what the type is.
I can also see this being a way to mask/unmask data at a granular level.