Skip to content

Commit

Permalink
fix: broken OpenAIModerationChain example (langchain-ai#2026)
Browse files Browse the repository at this point in the history
* fix: broken OpenAIModerationChain example

* run format
  • Loading branch information
chasemcdo authored Jul 20, 2023
1 parent c09f831 commit 9302454
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/src/chains/openai_moderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ const badString = "Bad naughty words from user";

try {
// Create a new instance of the OpenAIModerationChain
const moderation = new OpenAIModerationChain();
const moderation = new OpenAIModerationChain({
throwError: true, // If set to true, the call will throw an error when the moderation chain detects violating content. If set to false, violating content will return "Text was found that violates OpenAI's content policy.".
});

// Send the user's input to the moderation chain and wait for the result
const { output: badResult } = await moderation.call({
input: badString,
throwError: true, // If set to true, the call will throw an error when the moderation chain detects violating content. If set to false, violating content will return "Text was found that violates OpenAI's content policy.".
});

// If the moderation chain does not detect violating content, it will return the original input and you can proceed to use the result in another chain.
Expand Down

0 comments on commit 9302454

Please sign in to comment.