SDKs & clients
CLI that finds PII in text with TypeSafe Jev: presence, sensitivity, and located spans
import { choice, noul, score, TypeSafeClient } from "@typesafe-ai/sdk";The link points at the commit we read, so the line number still holds.
These question sets are lifted from this project's source exactly as written.
from src/gate.ts:35
person_nametrue/falseDoes the text mention the name of a specific individual person?
email_or_phonetrue/falseDoes the text contain an email address or phone number of a specific person?
postal_addresstrue/falseDoes the text contain a postal address associated with a specific person?
date_of_birthtrue/falseDoes the text contain the date of birth of a specific person?
government_idtrue/falseDoes the text contain a government-issued identifier of a person (e.g., マイナンバー, passport number, driver's licence number)?
financial_accounttrue/falseDoes the text contain a credit card number or bank account number of a person?
health_infotrue/falseDoes the text contain medical information, diagnosis, or treatment details of an identifiable person?
biometrictrue/falseDoes the text contain biometric data (fingerprint, facial recognition, iris scan) of a specific person?
import { experimental_evaluate as evaluate } from 'ai';
const { answers } = await evaluate({
model: 'typesafe-ai/jev',
state,
questions: {
person_name: { type: 'boolean', instructions: 'Does the text mention the name of a specific individual person?' },
email_or_phone: { type: 'boolean', instructions: 'Does the text contain an email address or phone number of a specific person?' },
postal_address: { type: 'boolean', instructions: 'Does the text contain a postal address associated with a specific person?' },
date_of_birth: { type: 'boolean', instructions: 'Does the text contain the date of birth of a specific person?' },
government_id: { type: 'boolean', instructions: 'Does the text contain a government-issued identifier of a person (e.g., マイナンバー, passport number, driver\'s licence number)?' },
financial_account: { type: 'boolean', instructions: 'Does the text contain a credit card number or bank account number of a person?' },
health_info: { type: 'boolean', instructions: 'Does the text contain medical information, diagnosis, or treatment details of an identifiable person?' },
biometric: { type: 'boolean', instructions: 'Does the text contain biometric data (fingerprint, facial recognition, iris scan) of a specific person?' },
},
});from src/locate.ts:62
is_personaltrue/falseIs the email address "
import { experimental_evaluate as evaluate } from 'ai';
const { answers } = await evaluate({
model: 'typesafe-ai/jev',
state,
questions: {
is_personal: { type: 'boolean', instructions: 'Is the email address "' },
},
});from src/locate.ts:101
digit_typechoiceIn `text`, what kind of number is 「${match.text}」?
my_number — マイナンバー or Japanese My Numbercredit_card — Credit card numberbank_account — Bank account numberphone — Phone number (mobile or landline)driver_licence_or_passport — Driver's licence or passport numbernational_id — Social security number or other national identification numberorder_or_tracking_number — Order number or parcel tracking numberproduct_serial — Product serial number or SKUdate — Date or date-related numberother — Other type of numberimport { experimental_evaluate as evaluate } from 'ai';
const { answers } = await evaluate({
model: 'typesafe-ai/jev',
state,
questions: {
digit_type: { type: 'choice', instructions: 'In `text`, what kind of number is 「${match.text}」?',
criteria: { my_number: 'マイナンバー or Japanese My Number', credit_card: 'Credit card number', bank_account: 'Bank account number', phone: 'Phone number (mobile or landline)', driver_licence_or_passport: 'Driver\'s licence or passport number', national_id: 'Social security number or other national identification number', order_or_tracking_number: 'Order number or parcel tracking number', product_serial: 'Product serial number or SKU', date: 'Date or date-related number', other: 'Other type of number' } },
},
});from src/locate.ts:150
is_personaltrue/falseIs the phone number "
import { experimental_evaluate as evaluate } from 'ai';
const { answers } = await evaluate({
model: 'typesafe-ai/jev',
state,
questions: {
is_personal: { type: 'boolean', instructions: 'Is the phone number "' },
},
});