explaining stuff was flagged).moderation_chain = OpenAIModerationChain()moderation_chain.run("This is okay")    'This is okay'moderation_chain.run("I will kill you")    "Text was found that violates OpenAI's content policy."Here's an example of using the moderation chain to throw an error.moderation_chain_error = OpenAIModerationChain(error=True)moderation_chain_error.run("This is okay")    'This is okay'moderation_chain_error.run("I will kill you")    ---------------------------------------------------------------------------    ValueError                                Traceback (most recent call last)    Cell In[7], line 1    ----> 1 moderation_chain_error.run("I will kill you")    File ~/workplace/langchain/langchain/chains/base.py:138, in Chain.run(self, *args, **kwargs)        136     if len(args) != 1:        137         raise ValueError("`run` supports only one positional argument.")    --> 138     return self(args[0])[self.output_keys[0]]        140 if kwargs and not args:        141     return self(kwargs)[self.output_keys[0]]    File ~/workplace/langchain/langchain/chains/base.py:112, in Chain.__call__(self, inputs, return_only_outputs)        108 if self.verbose:        109     print(        110         f"\n\n\033[1m> Entering new {self.__class__.__name__} chain...\033[0m"        111     )    --> 112 outputs = self._call(inputs)        113 if self.verbose:        114     print(f"\n\033[1m> Finished {self.__class__.__name__} chain.\033[0m")    File ~/workplace/langchain/langchain/chains/moderation.py:81, in OpenAIModerationChain._call(self, inputs)         79 text = inputs[self.input_key]         80 results = self.client.create(text)    ---> 81 output = self._moderate(text, results["results"][0])         82 return {self.output_key: output}    File ~/workplace/langchain/langchain/chains/moderation.py:73, in OpenAIModerationChain._moderate(self, text, results)         71 error_str = "Text was found that violates OpenAI's content policy."         72 if
This notebook walks through examples of how to use a moderation chain, and several common ways for doing so.
This notebook walks through examples of how to use a moderation chain, and several common ways for doing so. ->: explaining stuff was flagged).moderation_chain = OpenAIModerationChain()moderation_chain.run("This is okay")    'This is okay'moderation_chain.run("I will kill you")    "Text was found that violates OpenAI's content policy."Here's an example of using the moderation chain to throw an error.moderation_chain_error = OpenAIModerationChain(error=True)moderation_chain_error.run("This is okay")    'This is okay'moderation_chain_error.run("I will kill you")    ---------------------------------------------------------------------------    ValueError                                Traceback (most recent call last)    Cell In[7], line 1    ----> 1 moderation_chain_error.run("I will kill you")    File ~/workplace/langchain/langchain/chains/base.py:138, in Chain.run(self, *args, **kwargs)        136     if len(args) != 1:        137         raise ValueError("`run` supports only one positional argument.")    --> 138     return self(args[0])[self.output_keys[0]]        140 if kwargs and not args:        141     return self(kwargs)[self.output_keys[0]]    File ~/workplace/langchain/langchain/chains/base.py:112, in Chain.__call__(self, inputs, return_only_outputs)        108 if self.verbose:        109     print(        110         f"\n\n\033[1m> Entering new {self.__class__.__name__} chain...\033[0m"        111     )    --> 112 outputs = self._call(inputs)        113 if self.verbose:        114     print(f"\n\033[1m> Finished {self.__class__.__name__} chain.\033[0m")    File ~/workplace/langchain/langchain/chains/moderation.py:81, in OpenAIModerationChain._call(self, inputs)         79 text = inputs[self.input_key]         80 results = self.client.create(text)    ---> 81 output = self._moderate(text, results["results"][0])         82 return {self.output_key: output}    File ~/workplace/langchain/langchain/chains/moderation.py:73, in OpenAIModerationChain._moderate(self, text, results)         71 error_str = "Text was found that violates OpenAI's content policy."         72 if