@cendor/guardrails 0.4.0 → 0.6.0
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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters.d.ts +5 -3
- package/dist/adapters.d.ts.map +1 -1
- package/dist/adapters.js +6 -4
- package/dist/adapters.js.map +1 -1
- package/dist/decision.d.ts +10 -2
- package/dist/decision.d.ts.map +1 -1
- package/dist/decision.js +10 -0
- package/dist/decision.js.map +1 -1
- package/dist/embeddings.d.ts +49 -0
- package/dist/embeddings.d.ts.map +1 -0
- package/dist/embeddings.js +32 -0
- package/dist/embeddings.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -1
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +2 -1
- package/dist/intent.d.ts.map +1 -1
- package/dist/intent.js +37 -19
- package/dist/intent.js.map +1 -1
- package/dist/judge.d.ts +5 -4
- package/dist/judge.d.ts.map +1 -1
- package/dist/judge.js +17 -9
- package/dist/judge.js.map +1 -1
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +10 -2
- package/dist/rules.js.map +1 -1
- package/dist/semantic.d.ts +16 -13
- package/dist/semantic.d.ts.map +1 -1
- package/dist/semantic.js +70 -46
- package/dist/semantic.js.map +1 -1
- package/package.json +10 -2
package/dist/semantic.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Similarity checks over a **bring-your-own** embedding function — groundedness
|
|
3
|
-
* TS port of `cendor.guardrails.semantic`.
|
|
2
|
+
* Similarity checks over a **bring-your-own** embedding function — groundedness, denied-topics, and
|
|
3
|
+
* custom-category. The TS port of `cendor.guardrails.semantic`.
|
|
4
4
|
*
|
|
5
5
|
* - `groundedness` — trip when a response is **not** close enough to any provided source (a RAG
|
|
6
6
|
* hallucination gate).
|
|
7
7
|
* - `deniedTopics` — trip when the payload is **too** close to any denied-topic exemplar.
|
|
8
|
+
* - `customCategory` — trip when the payload is close to a category you define by example.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
* sentence-transformer, a hosted embeddings endpoint, anything).
|
|
11
|
-
* mirroring `cassette`'s bring-your-own-scorer.
|
|
12
|
-
*
|
|
13
|
-
* (
|
|
10
|
+
* All take an `embed(text) => number[] | Promise<number[]>` callable — **you** supply the model (a
|
|
11
|
+
* local sentence-transformer, a hosted embeddings endpoint, `embeddings.localEmbedder()`, anything).
|
|
12
|
+
* cendor ships **no** embedding model, mirroring `cassette`'s bring-your-own-scorer. `embed` may be
|
|
13
|
+
* **sync or async**: a sync embed keeps the check sync (usable via `apply` / `install`); an async
|
|
14
|
+
* embed (e.g. a hosted endpoint or `embeddings.localEmbedder()` via transformers.js) makes the check
|
|
15
|
+
* async — run it through `applyAsync` or the SDK loop. Cosine similarity is computed in pure TS.
|
|
16
|
+
* These are heuristics: a threshold you tune, not a guarantee. For richer, reasoned judgement, use the
|
|
14
17
|
* `judge` LLM-judge helpers instead.
|
|
15
18
|
*
|
|
16
19
|
* Imports only `./decision` and reuses `payloadText` from `./rules` (a hoisted function), so the
|
|
@@ -23,6 +26,14 @@ function resolveOnError(action, onError) {
|
|
|
23
26
|
return onError;
|
|
24
27
|
return action === 'flag' ? 'fail_open' : 'fail_closed';
|
|
25
28
|
}
|
|
29
|
+
function isThenable(x) {
|
|
30
|
+
return x != null && typeof x.then === 'function';
|
|
31
|
+
}
|
|
32
|
+
/** Apply `fn` to a value that may be a Promise, staying **sync when the value is sync**. `fn` may
|
|
33
|
+
* itself return a Promise; nested levels flatten (Promise.then), so the result is `R | Promise<R>`. */
|
|
34
|
+
function chain(v, fn) {
|
|
35
|
+
return isThenable(v) ? v.then(fn) : fn(v);
|
|
36
|
+
}
|
|
26
37
|
function cosine(a, b) {
|
|
27
38
|
let dot = 0;
|
|
28
39
|
let na = 0;
|
|
@@ -39,12 +50,24 @@ function cosine(a, b) {
|
|
|
39
50
|
return 0;
|
|
40
51
|
return dot / (Math.sqrt(na) * Math.sqrt(nb));
|
|
41
52
|
}
|
|
42
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Embed `texts` once, on first check (not at construction — so building an agent makes no call).
|
|
55
|
+
* Returns the vectors synchronously for a sync `embed`, or a Promise for an async one; the result is
|
|
56
|
+
* cached either way.
|
|
57
|
+
*/
|
|
43
58
|
function lazyVectors(embed, texts) {
|
|
44
59
|
let cache;
|
|
45
60
|
return () => {
|
|
46
|
-
if (cache
|
|
47
|
-
cache
|
|
61
|
+
if (cache !== undefined)
|
|
62
|
+
return cache;
|
|
63
|
+
const raw = texts.map((t) => embed(t));
|
|
64
|
+
if (raw.some(isThenable)) {
|
|
65
|
+
return Promise.all(raw.map((r) => Promise.resolve(r).then((v) => [...v]))).then((v) => {
|
|
66
|
+
cache = v;
|
|
67
|
+
return v;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
cache = raw.map((r) => [...r]);
|
|
48
71
|
return cache;
|
|
49
72
|
};
|
|
50
73
|
}
|
|
@@ -56,43 +79,43 @@ function lazyVectors(embed, texts) {
|
|
|
56
79
|
export function groundedness(embed, sources, opts = {}) {
|
|
57
80
|
const { threshold = 0.75, stage = 'output', action = 'flag', name = 'groundedness', timeout, onError, } = opts;
|
|
58
81
|
const sourceVecs = lazyVectors(embed, [...sources]);
|
|
59
|
-
const check = (payload, _ctx) => {
|
|
60
|
-
const vecs = sourceVecs();
|
|
82
|
+
const check = (payload, _ctx) => chain(sourceVecs(), (vecs) => {
|
|
61
83
|
if (vecs.length === 0)
|
|
62
84
|
return null;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
return chain(embed(payloadText(payload)), (answer) => {
|
|
86
|
+
const best = vecs.reduce((m, v) => Math.max(m, cosine([...answer], v)), 0);
|
|
87
|
+
if (best >= threshold)
|
|
88
|
+
return null;
|
|
89
|
+
return new Verdict(action, `ungrounded: max similarity ${best.toFixed(2)} < ${threshold}`);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
69
92
|
return defineGuardrail(check, { name, stage, timeout, onError: resolveOnError(action, onError) });
|
|
70
93
|
}
|
|
71
94
|
/**
|
|
72
95
|
* Trip when the payload is semantically close to a **custom category** you define by example — the
|
|
73
|
-
* local
|
|
74
|
-
*
|
|
96
|
+
* local counterpart to Azure Content Safety's *rapid custom categories* (description + examples →
|
|
97
|
+
* embedding search), with no cloud call and no training step. Trips when the payload's max cosine
|
|
75
98
|
* similarity to any example is **at or above** `threshold`, recording `metadata.category` /
|
|
76
99
|
* `metadata.score`; catches paraphrases `keywordDeny` misses. Defaults to `action:'flag'` (a tuned
|
|
77
100
|
* heuristic — calibrate before you block). No catch-rate claim; empty `examples` never trips.
|
|
78
101
|
*
|
|
79
|
-
* `embed(text)` is **bring-your-own** —
|
|
80
|
-
*
|
|
81
|
-
* Python-only; parity 🚧.)
|
|
102
|
+
* `embed(text)` is **bring-your-own** — sync (keeps the check usable via `apply`) or async (a hosted
|
|
103
|
+
* endpoint / `embeddings.localEmbedder()`, which makes the check async → use `applyAsync` / the SDK).
|
|
82
104
|
*/
|
|
83
105
|
export function customCategory(category, examples, embed, opts = {}) {
|
|
84
106
|
const { threshold = 0.8, stage = 'input', action = 'flag', name = `custom_category:${category}`, timeout, onError, } = opts;
|
|
85
107
|
const exampleVecs = lazyVectors(embed, [...examples]);
|
|
86
|
-
const check = (payload, _ctx) => {
|
|
87
|
-
const vecs = exampleVecs();
|
|
108
|
+
const check = (payload, _ctx) => chain(exampleVecs(), (vecs) => {
|
|
88
109
|
if (vecs.length === 0)
|
|
89
110
|
return null;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
111
|
+
return chain(embed(payloadText(payload)), (q) => {
|
|
112
|
+
const query = [...q];
|
|
113
|
+
const best = vecs.reduce((m, v) => Math.max(m, cosine(query, v)), Number.NEGATIVE_INFINITY);
|
|
114
|
+
if (best < threshold)
|
|
115
|
+
return null;
|
|
116
|
+
return new Verdict(action, `custom category ${JSON.stringify(category)}: sim ${best.toFixed(2)} >= ${threshold}`, null, { category, score: Math.round(best * 1e4) / 1e4 });
|
|
117
|
+
});
|
|
118
|
+
});
|
|
96
119
|
return defineGuardrail(check, { name, stage, timeout, onError: resolveOnError(action, onError) });
|
|
97
120
|
}
|
|
98
121
|
/**
|
|
@@ -104,24 +127,25 @@ export function deniedTopics(embed, topics, opts = {}) {
|
|
|
104
127
|
const { threshold = 0.8, stage = 'input', action = 'block', name = 'denied_topics', timeout, onError, } = opts;
|
|
105
128
|
const topicList = [...topics];
|
|
106
129
|
const topicVecs = lazyVectors(embed, topicList);
|
|
107
|
-
const check = (payload, _ctx) => {
|
|
108
|
-
const vecs = topicVecs();
|
|
130
|
+
const check = (payload, _ctx) => chain(topicVecs(), (vecs) => {
|
|
109
131
|
if (vecs.length === 0)
|
|
110
132
|
return null;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
bestSim
|
|
118
|
-
|
|
119
|
-
|
|
133
|
+
return chain(embed(payloadText(payload)), (q) => {
|
|
134
|
+
const query = [...q];
|
|
135
|
+
let bestI = 0;
|
|
136
|
+
let bestSim = Number.NEGATIVE_INFINITY;
|
|
137
|
+
vecs.forEach((v, i) => {
|
|
138
|
+
const s = cosine(query, v);
|
|
139
|
+
if (s > bestSim) {
|
|
140
|
+
bestSim = s;
|
|
141
|
+
bestI = i;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
if (bestSim < threshold)
|
|
145
|
+
return null;
|
|
146
|
+
return new Verdict(action, `denied topic ${JSON.stringify(topicList[bestI])}: sim ${bestSim.toFixed(2)} >= ${threshold}`);
|
|
120
147
|
});
|
|
121
|
-
|
|
122
|
-
return null;
|
|
123
|
-
return new Verdict(action, `denied topic ${JSON.stringify(topicList[bestI])}: sim ${bestSim.toFixed(2)} >= ${threshold}`);
|
|
124
|
-
};
|
|
148
|
+
});
|
|
125
149
|
return defineGuardrail(check, { name, stage, timeout, onError: resolveOnError(action, onError) });
|
|
126
150
|
}
|
|
127
151
|
//# sourceMappingURL=semantic.js.map
|
package/dist/semantic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"semantic.js","sourceRoot":"","sources":["../src/semantic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"semantic.js","sourceRoot":"","sources":["../src/semantic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAKL,OAAO,EACP,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAUzC,SAAS,cAAc,CAAC,MAAc,EAAE,OAAiB;IACvD,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IAC1C,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;AACzD,CAAC;AAED,SAAS,UAAU,CAAI,CAAU;IAC/B,OAAO,CAAC,IAAI,IAAI,IAAI,OAAQ,CAAwB,CAAC,IAAI,KAAK,UAAU,CAAC;AAC3E,CAAC;AAED;uGACuG;AACvG,SAAS,KAAK,CAAO,CAAiB,EAAE,EAA4B;IAClE,OAAO,UAAU,CAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAM,CAAC,CAAC;AACpD,CAAC;AAED,SAAS,MAAM,CAAC,CAAoB,EAAE,CAAoB;IACxD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAA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MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;gBAC3B,IAAI,CAAC,GAAG,OAAO,EAAE,CAAC;oBAChB,OAAO,GAAG,CAAC,CAAC;oBACZ,KAAK,GAAG,CAAC,CAAC;gBACZ,CAAC;YACH,CAAC,CAAC,CAAC;YACH,IAAI,OAAO,GAAG,SAAS;gBAAE,OAAO,IAAI,CAAC;YACrC,OAAO,IAAI,OAAO,CAChB,MAAM,EACN,gBAAgB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,SAAS,EAAE,CAC9F,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACL,OAAO,eAAe,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;AACpG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cendor/guardrails",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A local-first gate for LLM apps: define a check — keyword, regex, URL, length, JSON-schema — attach it to a stage (input, tool call, tool output, output). Deterministic, microsecond, $0, and every decision is audit-grade evidence.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,7 +23,15 @@
|
|
|
23
23
|
"node": ">=18"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@cendor/core": "^0.
|
|
26
|
+
"@cendor/core": "^0.5.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@huggingface/transformers": ">=3"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"@huggingface/transformers": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
27
35
|
},
|
|
28
36
|
"keywords": [
|
|
29
37
|
"llm",
|