Effortlessly Extract Personal Information with PII Actions

In today's data-driven world, the ability to efficiently extract personal identifiable information (PII) from text is crucial for businesses and developers alike. The PII Extractor LLM provides a powerful solution to identify and extract sensitive data such as names, addresses, and dates of birth from various text inputs. This service is specifically trained to recognize PII elements relevant to the Indian context, allowing developers to tailor their applications with precision and reliability.
By leveraging the PII Extractor, developers can streamline processes, enhance data management, and ensure compliance with privacy regulations. Common use cases include automating data extraction from customer feedback forms, processing resumes, and managing user profiles, thereby saving time and reducing manual errors.
Prerequisites
To get started with the PII Extractor LLM, you'll need an API key and a basic understanding of API calls.
Extract PII from Text
The "Extract PII from Text" action is designed to identify and extract personal identifiable information from a given text input. It addresses the challenges of manually sifting through unstructured data to find sensitive information, providing an automated solution that enhances efficiency.
Input Requirements
The action requires a JSON object containing the following fields:
- modelType (optional): Specifies the model to use, with options being 'm1_base' or 'm1_large', defaulting to 'm1_large'.
- inputString (required): The text from which information will be extracted. For example:
"Mukesh Dhirubhai Ambani (19-04-1957) is an Indian billionaire businessman. He is currently the chairman and managing director of Reliance Industries, India's most valuable company by market value. Resides at Antilla, No 10, Haji road, Mumbai."
Expected Output
The expected output is a JSON object that includes the extracted PII elements, such as:
- dob: The date of birth.
- name: The person's name.
- address: The address.
- fatherName: The name of the father (if available).
For instance, the output for the above input would be:
{
"dob": "19-04-1957",
"name": "Mukesh Dhirubhai Ambani",
"address": "at antilla, no 10, haji road, mumbai",
"fatherName": "NA"
}
Use Cases for this Specific Action
This action is particularly useful in scenarios such as:
- Customer Data Processing: Automatically extracting PII from user submissions or support tickets, enabling efficient data management.
- Resume Parsing: Extracting relevant information from job applications to streamline recruitment processes.
- Compliance Monitoring: Ensuring that sensitive data is accurately identified and handled according to data protection regulations.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "61a26d6f-1d26-4011-bdf5-c8ecce6d5fc0" # Action ID for: Extract PII from Text
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"inputString": "\"Mukesh Dhirubhai Ambani (19-04-1957) is an Indian billionaire businessman. He is currently the chairman and managing director of Reliance Industries, India's most valuable company by market value. Resides at Antilla, No 10, Haji road, Mumbai\""
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
print(json.dumps(result, indent=2))
except requests.exceptions.RequestException as e:
print(f"Error executing action {action_id}: {e}")
if e.response is not None:
print(f"Response status: {e.response.status_code}")
try:
print(f"Response body: {e.response.json()}")
except json.JSONDecodeError:
print(f"Response body (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
The PII Extractor LLM simplifies the extraction of personal identifiable information, enabling developers to enhance their applications with automated data processing capabilities. By utilizing this action, you can improve operational efficiency, ensure compliance, and reduce manual errors across various use cases. To get started, integrate the PII Extractor into your application and experience the benefits of streamlined data extraction today!