# PII detection with Eevo

> Eevo docs. Every page as Markdown is listed at https://eevo.io/llms.txt; the API is described at https://eevo.io/api/openapi.json.

Avoiding mishandling of personally identifiable information (PII) is a big challenge, especially when AI agents are working flexibly within organisations. The cost/performance and speed/performance of decision models make them well suited for implementing controls that seek to prevent PII leaks, for example as part of input and output safety checks on an agent's tool use.

Exactly how you implement PII detection with a decision model depends on your context. This guide serves as an indicative how-to for a typical setup that you should adapt to work in your context.

Below is an example of using Eevo to detect personally identifiable information:

**Python**

```python
import os

import requests

TEXT = """Hi, this is Maria Lindqvist. I was charged twice for order 48213, both times on the card ending in 4417. Please send the refund confirmation to maria.lindqvist@example.com."""

QUESTIONS = {
    "contains_pii": {
        "type": "noul",
        "instructions": "The text contains personally identifiable information.",
    },
    "name": {
        "type": "noul",
        "instructions": "The text contains a person’s full name.",
    },
    "contact": {
        "type": "noul",
        "instructions": "The text contains an email address, phone number or postal address.",
    },
    "payment": {
        "type": "noul",
        "instructions": "The text contains payment card or bank account details, even partial.",
    },
    "health": {
        "type": "noul",
        "instructions": "The text contains information about a person’s health.",
    },
}

response = requests.post(
    "https://eevo.io/api/v1/systemone",
    headers={"Authorization": f"Bearer {os.environ['EEVO_API_KEY']}"},
    json={"model": "eevo-1", "state": TEXT, "questions": QUESTIONS},
)
response.raise_for_status()
print(response.json()["answers"])
```

**TypeScript**

```typescript
const TEXT = `Hi, this is Maria Lindqvist. I was charged twice for order 48213, both times on the card ending in 4417. Please send the refund confirmation to maria.lindqvist@example.com.`;

const QUESTIONS = {
  "contains_pii": {
    "type": "noul",
    "instructions": "The text contains personally identifiable information."
  },
  "name": {
    "type": "noul",
    "instructions": "The text contains a person’s full name."
  },
  "contact": {
    "type": "noul",
    "instructions": "The text contains an email address, phone number or postal address."
  },
  "payment": {
    "type": "noul",
    "instructions": "The text contains payment card or bank account details, even partial."
  },
  "health": {
    "type": "noul",
    "instructions": "The text contains information about a person’s health."
  }
};

const response = await fetch('https://eevo.io/api/v1/systemone', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.EEVO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ model: 'eevo-1', state: TEXT, questions: QUESTIONS }),
});
if (!response.ok) throw new Error(`Eevo answered ${response.status}`);
console.log((await response.json()).answers);
```

**JavaScript**

```javascript
const TEXT = `Hi, this is Maria Lindqvist. I was charged twice for order 48213, both times on the card ending in 4417. Please send the refund confirmation to maria.lindqvist@example.com.`;

const QUESTIONS = {
  "contains_pii": {
    "type": "noul",
    "instructions": "The text contains personally identifiable information."
  },
  "name": {
    "type": "noul",
    "instructions": "The text contains a person’s full name."
  },
  "contact": {
    "type": "noul",
    "instructions": "The text contains an email address, phone number or postal address."
  },
  "payment": {
    "type": "noul",
    "instructions": "The text contains payment card or bank account details, even partial."
  },
  "health": {
    "type": "noul",
    "instructions": "The text contains information about a person’s health."
  }
};

const response = await fetch('https://eevo.io/api/v1/systemone', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.EEVO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ model: 'eevo-1', state: TEXT, questions: QUESTIONS }),
});
if (!response.ok) throw new Error(`Eevo answered ${response.status}`);
console.log((await response.json()).answers);
```

**Rust**

```rust
use serde_json::{json, Value};

const TEXT: &str = r#"Hi, this is Maria Lindqvist. I was charged twice for order 48213, both times on the card ending in 4417. Please send the refund confirmation to maria.lindqvist@example.com."#;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let questions = json!({
      "contains_pii": {
        "type": "noul",
        "instructions": "The text contains personally identifiable information."
      },
      "name": {
        "type": "noul",
        "instructions": "The text contains a person’s full name."
      },
      "contact": {
        "type": "noul",
        "instructions": "The text contains an email address, phone number or postal address."
      },
      "payment": {
        "type": "noul",
        "instructions": "The text contains payment card or bank account details, even partial."
      },
      "health": {
        "type": "noul",
        "instructions": "The text contains information about a person’s health."
      }
    });
    let response: Value = reqwest::Client::new()
        .post("https://eevo.io/api/v1/systemone")
        .bearer_auth(std::env::var("EEVO_API_KEY")?)
        .json(&json!({ "model": "eevo-1", "state": TEXT, "questions": questions }))
        .send()
        .await?
        .error_for_status()?
        .json()
        .await?;
    println!("{}", response["answers"]);
    Ok(())
}
```

In the snippet, there is a general question on whether there is PII, and specific questions targeting specific types of PII. The latter kind of question is useful if your organisation has a policy that distinguishes different types of personally identifiable information.

An example response is below:

```json
{
  "contains_pii": {
    "type": "noul",
    "noul": 0.9367
  },
  "name": {
    "type": "noul",
    "noul": 0.9578
  },
  "contact": {
    "type": "noul",
    "noul": 0.9704
  },
  "payment": {
    "type": "noul",
    "noul": 0.9281
  },
  "health": {
    "type": "noul",
    "noul": 0.0373
  }
}
```

As usual, the decision model provides probabilities reflecting its confidence in each answer. The probabilities allow for setting thresholds that trigger safeguards when there is a substantial risk of PII leaking.

## Read next

- [Data controls](https://eevo.io/api/docs/reference/data-controls.md): Controlling retention, training use and processing region of your requests.
- [SystemOne decision](https://eevo.io/api/docs/reference/api-systemone.md): POST /api/v1/systemone
- [Probability, confidence and expected value](https://eevo.io/api/docs/explanation/probability-and-ev.md): Learn what the probabilities in an answer mean.
