@lacspace/condense
Extractive multi-source condenser — turn several articles on one story into a short, deduplicated, token-budgeted digest that keeps the numbers, quotes and named entities, so an LLM only rewrites a fraction of the text. BM25 sentence ranking, near-duplicate removal, per-source attribution with char offsets, Devanagari-aware (।/॥, ०-९, रु). Deterministic, isomorphic.
npm i @lacspace/condenseUsage
import { condense } from "@lacspace/condense";
const digest = condense(
[
{ text: kathmanduPost, label: "Kathmandu Post" },
{ text: himalayanTimes, label: "Himalayan Times" },
{ text: onlineKhabar, label: "Online Khabar" },
],
{ tokenBudget: 1500, gazetteer: ["Nepal Rastra Bank", "\u0928\u0947\u092a\u093e\u0932 \u0930\u093e\u0937\u094d\u091f\u094d\u0930 \u092c\u0948\u0902\u0915"] },
);
digest.text; // kept sentences grouped per source under [S1 Kathmandu Post] headers
digest.tokens; // \u2264 tokenBudget
digest.droppedDup; // near-duplicate sentences removed across sources
// Feed digest.text to the model instead of six full articles.Exports 2
condensesplitSentencesKeywords
More in LLM Efficiency
A cheap lexical content screener and LLM admission gate — score text against your own weighted, multi-language term lexicons (with negation, proximity windows and a named-entity gazetteer) and get a clear / review / block decision, so obviously-clean and obviously-flagged text never reaches an expensive model. Deterministic, auditable, isomorphic.
@lacspace/keyphraseExtractive keyphrases, tags, hashtags, named entities and category votes — a zero-dependency RAKE + TF-IDF engine with built-in English and Nepali stopwords, Devanagari-aware, so you can stop asking an LLM to generate tags/hashtags/entities. Deterministic, isomorphic.
@lacspace/llm-cacheA content-hash cache for LLM calls — key by (model family, prompt version, normalized input) so identical requests, retries after a 429 and repeated rewrites never pay twice. Pluggable async store (in-memory LRU built in, Mongo/Redis/KV via an adapter), TTL, stale-if-error and a wrap() memoizer. Zero-dependency, isomorphic.
@lacspace/keypoolProvider-agnostic API-key rotation and rate-limit accounting — pool N free keys per provider, track RPM/RPD/TPM/TPD windows (per model), round-robin among healthy keys, cool down on 429 via retry-after, quarantine invalid keys, and share state across processes via an adapter. pick(provider, model, estTokens) → key | null. Zero-dependency, isomorphic.