feat: multi-turn conversation support (0.4.0)
anonymizeTurn(text, session) threads a serializable AnonymizerSession
({mapping, legend, history}) so one entity keeps one id across a whole chat
(applyKnown reuse + usedIds + de-collision merge). Adds conversation()
in-memory wrapper and an optional LlmProvider.anonymizeInConversation(text, ctx)
for rich cross-turn context; providers without it fall back to the batch path.
openAICompatibleProvider gains includeMappingInContext (default false — only
send real values to a trusted anonymizer endpoint) + historyMaxTurns (default
10). Verified live vs Gemma 4: Nora stays PER_1 across 4 turns (name/email/AVS/
IBAN), Yanis = PER_2; 41 tests, 98% coverage.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
18
CHANGELOG.md
18
CHANGELOG.md
@@ -4,6 +4,24 @@ All notable changes to this project are documented here. The format is based on
|
||||
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to
|
||||
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [0.4.0] - Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- **Multi-turn conversation support.** New `Anonymizer.anonymizeTurn(text, session?) → { anon, mapping,
|
||||
legend, session }` keeps one stable id per entity across a whole chat: it seeds each turn with a running,
|
||||
serializable `AnonymizerSession` (`{ mapping, legend, history }`), reuses known values via `applyKnown`,
|
||||
tells the model which ids are taken, and de-collides new ones. Persist the returned `session` and pass it
|
||||
back next turn.
|
||||
- `Anonymizer.conversation(initial?)` — a stateful in-memory wrapper (`anonymize`, `deanonymize`,
|
||||
`session()`) over `anonymizeTurn`.
|
||||
- Optional `LlmProvider.anonymizeInConversation(text, ctx)` — providers can use prior context (anonymized
|
||||
`history`, `legend`, `usedIds`, and optionally `mapping`) for better cross-turn coreference/attribution.
|
||||
`openAICompatibleProvider` implements it; providers that don't fall back to the batch path automatically.
|
||||
- `openAICompatibleProvider` options: `includeMappingInContext` (**default false** — only send real values
|
||||
to a _trusted_ anonymizer endpoint) and `historyMaxTurns` via `AnonymizerConfig` (default 10).
|
||||
- Exported the `AnonymizerSession` type.
|
||||
|
||||
## [0.3.1] - Unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
Reference in New Issue
Block a user