llm-output-guard 1.11.2 → 1.11.4
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/README.md +11 -3
- package/dist/ai-sdk.cjs.map +1 -1
- package/dist/ai-sdk.d.cts +1 -1
- package/dist/ai-sdk.d.ts +1 -1
- package/dist/ai-sdk.js.map +1 -1
- package/dist/anthropic.cjs.map +1 -1
- package/dist/anthropic.d.cts +1 -1
- package/dist/anthropic.d.ts +1 -1
- package/dist/anthropic.js.map +1 -1
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js.map +1 -1
- package/dist/google.cjs.map +1 -1
- package/dist/google.d.cts +1 -1
- package/dist/google.d.ts +1 -1
- package/dist/google.js.map +1 -1
- package/dist/openai.cjs.map +1 -1
- package/dist/openai.d.cts +1 -1
- package/dist/openai.d.ts +1 -1
- package/dist/openai.js.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -90,9 +90,15 @@ a boolean** — you pick the line.
|
|
|
90
90
|
import OpenAI from 'openai';
|
|
91
91
|
import { withOutputGuard } from 'llm-output-guard/openai';
|
|
92
92
|
|
|
93
|
-
const client = withOutputGuard(new OpenAI(), { ...presets.chat, onDegenerate: '
|
|
93
|
+
const client = withOutputGuard(new OpenAI(), { ...presets.chat, onDegenerate: 'throw' });
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
+
`onDegenerate` decides what a failed check does: **`'throw'`** (the default)
|
|
97
|
+
fails the call, and on a stream also cancels the request. `'abort'` is the
|
|
98
|
+
streaming-only alternative — it ends the stream and keeps what arrived, and on a
|
|
99
|
+
non-streaming call it stops nothing. `'ignore'` reports and changes nothing,
|
|
100
|
+
which is how to roll out.
|
|
101
|
+
|
|
96
102
|
Adapters for the **OpenAI SDK** (both `chat.completions` and `responses`),
|
|
97
103
|
**Anthropic**, **Google Gemini** and the **Vercel AI SDK** — plus anything
|
|
98
104
|
speaking OpenAI's protocol: Groq, Together, OpenRouter, Fireworks, vLLM,
|
|
@@ -207,7 +213,9 @@ withOutputGuard(new OpenAI(), { ...presets.chat, checkPromptEcho: true });
|
|
|
207
213
|
```
|
|
208
214
|
|
|
209
215
|
Not for rewrite, translate or summarise endpoints, where copying the input is
|
|
210
|
-
the job.
|
|
216
|
+
the job. Abstains under 40 words, so a one-line prompt echoed perfectly still
|
|
217
|
+
scores 0.000.
|
|
218
|
+
[More →](docs/detectors.md#returning-the-prompt-instead-of-an-answer)
|
|
211
219
|
|
|
212
220
|
## The verdict
|
|
213
221
|
|
|
@@ -268,7 +276,7 @@ because only one of those is evidence.
|
|
|
268
276
|
|
|
269
277
|
- **Zero runtime dependencies**, enforced in CI. Node ≥ 18; works on edge, browser, Deno, Bun.
|
|
270
278
|
- **The size claim is a budget, not a memory.** `npm run size` bundles each entry, minifies and gzips it, and fails over budget — enforced in CI beside the zero-dependency check, because a number in prose is the cheapest thing in a repo to go stale.
|
|
271
|
-
- **Types resolve on old and new TypeScript alike
|
|
279
|
+
- **Types resolve on old and new TypeScript alike**, and it is checked rather than assumed. `npm run check:resolution` packs the tarball and typechecks every entry point under `node`, `node16`, `nodenext` and `bundler` on TypeScript 5 and 7 — enforced in CI. `moduleResolution: "node"` ignores the `exports` map, which is why `typesVersions` is there too.
|
|
272
280
|
- **Pure and synchronous.** No network, no clock, no randomness — safe on a hot path, trivial to test.
|
|
273
281
|
- **Scores, not booleans.** Detectors report 0–1 and leave the threshold decision to you.
|
|
274
282
|
- **Abstains rather than guesses.** Samples too short to judge score 0.
|