Let's see how PII anonymization works using a sample sentence:from langchain_experimental.data_anonymizer import PresidioAnonymizeranonymizer = PresidioAnonymizer()anonymizer.anonymize(    "My name is Slim Shady, call me at 313-666-7440 or email me at real.slim.shady@gmail.com")    'My name is James Martinez, call me at (576)928-1972x679 or email me at lisa44@example.com'Using with LangChain Expression Language‚ÄãWith LCEL we can easily chain together anonymization with the rest of our application.# Set env var OPENAI_API_KEY or load from a .env file:# import dotenv# dotenv.load_dotenv()text = f"""Slim Shady recently lost his wallet. Inside is some cash and his credit card with the number 4916 0387 9536 0861. If you would find it, please call at 313-666-7440 or write an email here: real.slim.shady@gmail.com."""from langchain.prompts.prompt import PromptTemplatefrom langchain.chat_models import ChatOpenAIanonymizer = PresidioAnonymizer()template = """Rewrite this text into an official, short email:{anonymized_text}"""prompt = PromptTemplate.from_template(template)llm = ChatOpenAI(temperature=0)chain = {"anonymized_text": anonymizer.anonymize} | prompt | llmresponse = chain.invoke(text)print(response.content)    Dear Sir/Madam,        We regret to inform you that Mr. Dennis Cooper has recently misplaced his wallet. The wallet contains a sum of cash and his credit card, bearing the number 3588895295514977.         Should you happen to come across the aforementioned wallet, kindly contact us immediately at (428)451-3494x4110 or send an email to perryluke@example.com.        Your prompt assistance in this matter would be greatly appreciated.        Yours faithfully,        [Your Name]Customization‚ÄãWe can specify analyzed_fields to only anonymize particular types of data.anonymizer = PresidioAnonymizer(analyzed_fields=["PERSON"])anonymizer.anonymize(    "My name is Slim Shady, call me at 313-666-7440 or email me at real.slim.shady@gmail.com")    'My name is Shannon
Open In Colab
Open In Colab ->: Let's see how PII anonymization works using a sample sentence:from langchain_experimental.data_anonymizer import PresidioAnonymizeranonymizer = PresidioAnonymizer()anonymizer.anonymize(    "My name is Slim Shady, call me at 313-666-7440 or email me at real.slim.shady@gmail.com")    'My name is James Martinez, call me at (576)928-1972x679 or email me at lisa44@example.com'Using with LangChain Expression Language‚ÄãWith LCEL we can easily chain together anonymization with the rest of our application.# Set env var OPENAI_API_KEY or load from a .env file:# import dotenv# dotenv.load_dotenv()text = f"""Slim Shady recently lost his wallet. Inside is some cash and his credit card with the number 4916 0387 9536 0861. If you would find it, please call at 313-666-7440 or write an email here: real.slim.shady@gmail.com."""from langchain.prompts.prompt import PromptTemplatefrom langchain.chat_models import ChatOpenAIanonymizer = PresidioAnonymizer()template = """Rewrite this text into an official, short email:{anonymized_text}"""prompt = PromptTemplate.from_template(template)llm = ChatOpenAI(temperature=0)chain = {"anonymized_text": anonymizer.anonymize} | prompt | llmresponse = chain.invoke(text)print(response.content)    Dear Sir/Madam,        We regret to inform you that Mr. Dennis Cooper has recently misplaced his wallet. The wallet contains a sum of cash and his credit card, bearing the number 3588895295514977.         Should you happen to come across the aforementioned wallet, kindly contact us immediately at (428)451-3494x4110 or send an email to perryluke@example.com.        Your prompt assistance in this matter would be greatly appreciated.        Yours faithfully,        [Your Name]Customization‚ÄãWe can specify analyzed_fields to only anonymize particular types of data.anonymizer = PresidioAnonymizer(analyzed_fields=["PERSON"])anonymizer.anonymize(    "My name is Slim Shady, call me at 313-666-7440 or email me at real.slim.shady@gmail.com")    'My name is Shannon