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 self.error:
---> 73 raise ValueError(error_str)
74 else:
75 return error_str
ValueError: Text was found that violates OpenAI's content policy.
```
</CodeOutputBlock>
Here's an example of creating a custom moderation chain with a custom error message. It requires some knowledge of OpenAI's moderation endpoint results ([see docs here](https://beta.openai.com/docs/api-reference/moderations)).
error_str = f"The following text was found that violates OpenAI's content policy: {text}"
return error_str
return text
custom_moderation = CustomModeration()
```
```python
custom_moderation.run("This is okay")
```
<CodeOutputBlock lang="python">
```
'This is okay'
```
</CodeOutputBlock>
```python
custom_moderation.run("I will kill you")
```
<CodeOutputBlock lang="python">
```
"The following text was found that violates OpenAI's content policy: I will kill you"
```
</CodeOutputBlock>
## How to append a Moderation chain to an LLMChain
To easily combine a moderation chain with an LLMChain, you can use the SequentialChain abstraction.
Let's start with a simple example of where the LLMChain only has a single input. For this purpose, we will prompt the model so it says something harmful.
"Text was found that violates OpenAI's content policy."
```
</CodeOutputBlock>
Now let's walk through an example of using it with an LLMChain which has multiple inputs (a bit more tricky because we can't use the SimpleSequentialChain)