griptape icon indicating copy to clipboard operation
griptape copied to clipboard

Add `RunnableMixin` for pre/post processing on arbitrary run execution

Open vachillo opened this issue 1 year ago • 3 comments

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.

vachillo avatar Jul 02 '24 00:07 vachillo

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?

collindutter avatar Aug 29 '24 22:08 collindutter

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.

vachillo avatar Aug 30 '24 01:08 vachillo

I can also see this being a way to mask/unmask data at a granular level.

vachillo avatar Aug 30 '24 01:08 vachillo