"threshold":0.5,},   }amazon_comp_moderation = AmazonComprehendModerationChain(moderation_config=moderation_config,                                                          client=comprehend_client ,                                                         verbose=True)The moderation_config will now prevent any inputs and model outputs containing obscene words or sentences, bad intent, or Pii with entities other than SSN with score above threshold or 0.5 or 50%. If it finds Pii entities - SSN - it will redact them before allowing the call to proceed. chain = (    prompt     | amazon_comp_moderation     | {llm_chain.input_keys[0]: lambda x: x['output'] }      | llm_chain     | { "input": lambda x: x['text'] }     | amazon_comp_moderation )try:    response = chain.invoke({"question": "My AnyCompany Financial Services, LLC credit card account 1111-0000-1111-0008 has 24$ due by July 31st. Can you give me some more samples?"})except Exception as e:    print(str(e))else:    print(response['output'])PreviousSafetyNextConstitutional chainSetting upUsing AmazonComprehendModerationChain with LLM chainUsing moderation_config to customize your moderationUnique ID, and Moderation Callbacksmoderation_config and moderation execution orderExamplesWith Hugging Face Hub ModelsWith Amazon SageMaker JumpstartCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.
This notebook shows how to use Amazon Comprehend to detect and handle Personally Identifiable Information (PII) and toxicity.
This notebook shows how to use Amazon Comprehend to detect and handle Personally Identifiable Information (PII) and toxicity. ->: "threshold":0.5,},   }amazon_comp_moderation = AmazonComprehendModerationChain(moderation_config=moderation_config,                                                          client=comprehend_client ,                                                         verbose=True)The moderation_config will now prevent any inputs and model outputs containing obscene words or sentences, bad intent, or Pii with entities other than SSN with score above threshold or 0.5 or 50%. If it finds Pii entities - SSN - it will redact them before allowing the call to proceed. chain = (    prompt     | amazon_comp_moderation     | {llm_chain.input_keys[0]: lambda x: x['output'] }      | llm_chain     | { "input": lambda x: x['text'] }     | amazon_comp_moderation )try:    response = chain.invoke({"question": "My AnyCompany Financial Services, LLC credit card account 1111-0000-1111-0008 has 24$ due by July 31st. Can you give me some more samples?"})except Exception as e:    print(str(e))else:    print(response['output'])PreviousSafetyNextConstitutional chainSetting upUsing AmazonComprehendModerationChain with LLM chainUsing moderation_config to customize your moderationUnique ID, and Moderation Callbacksmoderation_config and moderation execution orderExamplesWith Hugging Face Hub ModelsWith Amazon SageMaker JumpstartCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright ¬© 2023 LangChain, Inc.