griptape
griptape copied to clipboard
Add before and after hooks for masking data in prompts
Some users would like to mask and unmask data that goes out to external APIs as part the LLM prompt (e.g., customer PII). To solve this problem I propose adding the following to the framework:
- Add
BasePromptStackProcessor
class that containsbefore_run
andafter_run
methods. Let's think of better names. - Add
prompt_stack_processors: list[PromptStackProcessork]
property that contains a list of optional prompt stack processors. - Run
PromptStackProcessor.before_run
inBasePromptDriver.before_run
and PromptStackProcessor.after_runin
BasePromptDriver.after_run` in all prompt processors. - Add
AmazonComprehendPiiProcessor
that uses Amazon Comprehend to filter out PII data. - Add
PromptDriverPiiProcessor
that can use an arbitrary prompt driver to filter out PII data.
can I work on this?