BlindLLM
BlindLLM is a Python library that provides a secure way to interact with LLM APIs by automatically anonymizing sensitive information in prompts and de-anonymizing the responses. It supports multiple LLM services including OpenAI, Mistral, and Claude.
Features
- Automatic anonymization of sensitive data (names, emails, organizations, phone numbers, etc.)
- Support for multiple LLM services:
- OpenAI (GPT-4o, GPT-4, GPT-3.5-turbo)
- Mistral AI
- Anthropic's Claude
- Simple, unified interface for all supported services
- Automatic de-anonymization of responses
Installation
pip install .
Requirements
- Python 3.8 or higher
- API keys for the services you plan to use
- text_anonymizer library
Quick Start
from blindllm import BlindLLM
# Initialize with your chosen service
llm = BlindLLM(
service="openai", # or "mistral" or "claude"
model="gpt-4", # model name for the chosen service
api_key="your-api-key"
)
# Make a call - get all information including anonymized data
prompt = "John Smith from Acme Corp (email: john.smith@acme.com) asked about the project status."
result = llm.call(prompt)
# Access all available information
print(result['anonymized_prompt']) # The anonymized version of your prompt
print(result['anonymized_response']) # The raw response from the LLM
print(result['response']) # The final de-anonymized response
print(result['anonymization_map']) # The mapping of tokens to original values
Supported Services and Models
OpenAI
- gpt-4o
- gpt-4
- gpt-3.5-turbo
- And other available OpenAI chat models
Mistral
- mistral-large-latest
- mistral-medium-latest
- mistral-small-latest
- mistral-tiny-latest
Claude
- claude-3-5-sonnet-20241022
- claude-3-opus-20240229
- claude-3-sonnet-20240229
- claude-3-haiku-20240307
- And other available Claude models
How It Works
-
Anonymization: When you make a call, BlindLLM uses the
text_anonymizerlibrary to anonymize sensitive information in your prompt by replacing it with tokens (e.g., [ENTITY_PERSON_1], [ENTITY_EMAIL_1], [ENTITY_ORG_1]). -
API Call: The anonymized prompt is sent to the chosen LLM service.
-
De-anonymization: The response from the LLM is automatically de-anonymized by replacing the tokens with the original sensitive information.
Example
from blindllm import BlindLLM
llm = BlindLLM(
service="openai",
model="gpt-4",
api_key="your-openai-api-key"
)
# Example of what happens behind the scenes:
# 1. Your prompt:
prompt = "John Smith from Acme Corp (email: john.smith@acme.com) asked about the project status."
# 2. Anonymized before sending to API:
# result['anonymized_prompt'] will be something like:
# "[ENTITY_PERSON_1] from [ENTITY_ORG_1] (email: [ENTITY_EMAIL_1]) asked about the project status."
# 3. Raw LLM response with anonymized tokens:
# result['anonymized_response'] contains the direct response from the LLM
# 4. Final de-anonymized response:
# result['response'] contains the response with original names restored
# 5. Mapping information:
# result['anonymization_map'] contains:
# {
# "[ENTITY_PERSON_1]": "John Smith",
# "[ENTITY_ORG_1]": "Acme Corp",
# "[ENTITY_EMAIL_1]": "john.smith@acme.com"
# }
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for blindllm 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| blindllm-0.1.0.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| blindllm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.1 kB
Release files / blindllm-0.1.0.tar.gz
| Download URL | blindllm-0.1.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d2c5659d232e1804accc050f757cc9feac3dd90f7254c2cdbac321081272f96
|
|
BLAKE2b-256 checksum How to use checksums |
82648989e665b74a845465529f79decdcbfc311cc3f93e163222e1a7ee4c2ce6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|
Release files / blindllm-0.1.0-py3-none-any.whl
| Download URL | blindllm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f184ca2a44d59945dbc69b8102eb0ff3d3da3504edb361b8c2264a6b681cff19
|
|
BLAKE2b-256 checksum How to use checksums |
c172e1d74d5f6baa41e3f20519f16b11e0bf4d4bb8944a220b70105120733ed8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.7
|