maskflow-sdk 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
maskflow/__init__.py ADDED
@@ -0,0 +1,13 @@
1
+ from maskflow_core import Finding, MaskResult, PIIType, detect, mask, unmask
2
+
3
+ from .sdk import mask_and_call
4
+
5
+ __all__ = [
6
+ "detect",
7
+ "mask",
8
+ "unmask",
9
+ "mask_and_call",
10
+ "Finding",
11
+ "PIIType",
12
+ "MaskResult",
13
+ ]
maskflow/sdk.py ADDED
@@ -0,0 +1,23 @@
1
+ from typing import Callable
2
+
3
+ from maskflow_core import mask, unmask
4
+ from maskflow_core.detection import DEFAULT_MIN_CONFIDENCE
5
+
6
+
7
+ def mask_and_call(
8
+ prompt: str,
9
+ call_fn: Callable[[str], str],
10
+ min_confidence: float = DEFAULT_MIN_CONFIDENCE,
11
+ ) -> str:
12
+ """Mask PII in `prompt`, pass the masked text to `call_fn`, and restore the
13
+ original values in whatever `call_fn` returns.
14
+
15
+ `call_fn` is any function that takes a string and returns a string --
16
+ typically a closure around an LLM provider's client call. This makes
17
+ mask_and_call provider-agnostic: it works with Claude, OpenAI, Gemini, a
18
+ local model, or anything else, without MaskFlow depending on any
19
+ provider's SDK.
20
+ """
21
+ result = mask(prompt, min_confidence=min_confidence)
22
+ response = call_fn(result.masked_text)
23
+ return unmask(response, result.mapping)
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: maskflow-sdk
3
+ Version: 0.1.0
4
+ Summary: Mask PII before it reaches an LLM, unmask the response. Works with any provider.
5
+ License: MIT
6
+ Requires-Python: >=3.9
7
+ Requires-Dist: maskflow-core<0.2,>=0.1.0
8
+ Provides-Extra: dev
9
+ Requires-Dist: pytest>=8.0; extra == 'dev'
10
+ Description-Content-Type: text/markdown
11
+
12
+ # maskflow
13
+
14
+ Mask PII before it reaches an LLM. Unmask the response. Works with any provider.
15
+
16
+ ```python
17
+ from maskflow import mask_and_call
18
+
19
+ def call_claude(masked_prompt: str) -> str:
20
+ return anthropic_client.messages.create(
21
+ model="claude-sonnet-5",
22
+ max_tokens=1024,
23
+ messages=[{"role": "user", "content": masked_prompt}],
24
+ ).content[0].text
25
+
26
+ response = mask_and_call(
27
+ "Hi, I'm Jane Doe (jane@example.com). My order shipped to 123 Main St but never arrived.",
28
+ call_claude,
29
+ )
30
+ # Claude only ever sees "Hi, I'm <PERSON_NAME_1> (<EMAIL_1>). My order shipped to
31
+ # <ADDRESS_1> but never arrived." -- response comes back with the real values restored.
32
+ ```
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ pip install maskflow-sdk
38
+ ```
39
+
40
+ ## Why this shape
41
+
42
+ `mask_and_call` takes a plain function, not a specific provider's client. You write the one line
43
+ that actually calls your LLM (Claude, OpenAI, Gemini, a local model, anything) -- maskflow never
44
+ parses or depends on any provider's SDK, so it doesn't break when a provider changes their API and
45
+ works with providers it's never heard of.
46
+
47
+ ```python
48
+ response = mask_and_call(prompt, lambda masked: my_llm_client.generate(masked))
49
+ ```
50
+
51
+ ## Lower-level API
52
+
53
+ For more control than the wrapper gives, `mask`/`unmask` are available directly and are pure,
54
+ stateless functions -- no files, no database. Persisting the mapping between calls is your
55
+ responsibility.
56
+
57
+ ```python
58
+ from maskflow import mask, unmask
59
+
60
+ result = mask("Email me at alice@example.com.")
61
+ result.masked_text # "Email me at <EMAIL_1>."
62
+ result.mapping # {"<EMAIL_1>": "alice@example.com"}
63
+
64
+ unmask(result.masked_text, result.mapping) # original text, restored
65
+ ```
66
+
67
+ ## What gets detected
68
+
69
+ Email, phone, SSN, credit card, IP address, AWS access key, API key / generic secret, JWT, IBAN,
70
+ street address, person name, date of birth -- via regex + structural validation (Luhn, mod-97,
71
+ etc.) plus spaCy NER for names and dates, with keyword-context confidence boosting. See
72
+ [`maskflow-core`](../../core) for detection internals.
73
+
74
+ ## Tests
75
+
76
+ ```bash
77
+ uv run pytest
78
+ ```
@@ -0,0 +1,5 @@
1
+ maskflow/__init__.py,sha256=Foc6txGSWkLcXiSge8bMN5GqmYfaLwuCDfWjNXqwHzs,233
2
+ maskflow/sdk.py,sha256=c-bq8QLc8_n8VQlb1iOQ_XjaCh2Qsyh5RIFSrtQlCn8,859
3
+ maskflow_sdk-0.1.0.dist-info/METADATA,sha256=IF_lyApnC8Pjqr1CObvd3WewRSehRfprdyBVbn05YZo,2406
4
+ maskflow_sdk-0.1.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
5
+ maskflow_sdk-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any