From 3e39d3bbd527982dc482359046f208081f9d6f60 Mon Sep 17 00:00:00 2001 From: Shinwoo PARK Date: Mon, 11 May 2026 12:19:58 +0900 Subject: [PATCH] docs: document LLM extractor adapter usage --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 092a073..a9188ef 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,29 @@ await db.ingestStatement('Bun makes TypeScript tooling fast.', { }); ``` +## LLM-backed extraction + +You can bridge any text-generating model into IdentityDB by wrapping it with `LlmFactExtractor`. + +```ts +import { LlmFactExtractor } from 'identitydb'; + +const extractor = new LlmFactExtractor({ + model: { + async generateText(prompt) { + return callYourFavoriteLlm(prompt); + }, + }, + instructions: 'Prefer technology, product, and time topics over generic nouns.', +}); + +await db.ingestStatement('I have worked with Bun and TypeScript since 2025.', { + extractor, +}); +``` + +The adapter expects the model to return JSON and will validate the structured response before IdentityDB writes a fact. + ## Development ```bash