import gradio as gr from pangea.services import Redact import os def redact_input(input: str, pangea_token: str): redact = Redact(token=pangea_token) return redact.redact(text=input).result.redacted_text input_text = gr.components.Textbox(label="Enter your data here", value='My credit card number is 4242424242424242 with first and last name Mark Wittner and phone number 240-555-2323 \n City: New York \n State: NY') output_text1 = gr.components.Textbox(label="Redacted data") def main(pangea_token, input_text): if pangea_token == "defualt": pangea_token = os.environ["PANGEA_REDACT_TOKEN"] redacted_text = redact_input(input_text, pangea_token) return redacted_text pangea_token_input = gr.components.Textbox(label="Pangea Redact Token (Optional)", type="password", value="defualt", placeholder="pts_.....") iface = gr.Interface( fn=main, inputs=[pangea_token_input, input_text], outputs=[output_text1], title="Data Redaction Playground", description="
Enter your your Pangea redact token (optional for custom settings), then put in your data and watch the magic happen 🪄.
\ Data redaction is powered by Pangea's APIs in this demo. To learn more about how to get your API keys and tokens to run this, watch this short walkthrough demo
", allow_flagging="never" ) iface.launch( favicon_path="./favicon-32x32.png" )