vectorjson 0.4.0 → 0.4.1
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 +3 -19
- package/dist/engine-wasm.generated.d.ts +1 -1
- package/dist/engine-wasm.generated.d.ts.map +1 -1
- package/dist/engine.wasm +0 -0
- package/dist/index.js +5 -5
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -242,22 +242,6 @@ const result = parser.getValue(); // lazy Proxy — materializes on access
|
|
|
242
242
|
parser.destroy();
|
|
243
243
|
```
|
|
244
244
|
|
|
245
|
-
### Vercel AI SDK-compatible signature
|
|
246
|
-
|
|
247
|
-
If you have code that calls `parsePartialJson`, VectorJSON provides a compatible function:
|
|
248
|
-
|
|
249
|
-
```js
|
|
250
|
-
// Before
|
|
251
|
-
import { parsePartialJson } from "ai";
|
|
252
|
-
const { value, state } = parsePartialJson(buffer);
|
|
253
|
-
|
|
254
|
-
// After
|
|
255
|
-
import { parsePartialJson } from "vectorjson";
|
|
256
|
-
const { value, state } = parsePartialJson(buffer);
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
> **Note:** AI SDKs (Vercel, Anthropic, TanStack) parse JSON internally inside `streamObject()`, `MessageStream`, etc. — you don't get access to the raw chunks. To use VectorJSON today, work with the raw LLM stream directly (raw fetch, WebSocket, SSE).
|
|
260
|
-
|
|
261
245
|
### Event-driven: React to fields as they stream in
|
|
262
246
|
|
|
263
247
|
When an LLM streams a tool call, you usually care about specific fields at specific times. `createEventParser` lets you subscribe to paths and get notified the moment a value completes or a string grows:
|
|
@@ -350,7 +334,7 @@ for await (const partial of createParser({ source: chunks() })) {
|
|
|
350
334
|
|
|
351
335
|
Validate and auto-infer types with Zod, Valibot, ArkType, or any lib with `.safeParse()`. Works on all three APIs:
|
|
352
336
|
|
|
353
|
-
**Streaming parser with typed partial objects
|
|
337
|
+
**Streaming parser with typed partial objects:**
|
|
354
338
|
|
|
355
339
|
```ts
|
|
356
340
|
import { z } from 'zod';
|
|
@@ -569,7 +553,7 @@ Works with Zod, Valibot, ArkType — any library with `{ safeParse(v) → { succ
|
|
|
569
553
|
|
|
570
554
|
### `parsePartialJson(input, schema?): PartialJsonResult<DeepPartial<T>>`
|
|
571
555
|
|
|
572
|
-
|
|
556
|
+
One-shot partial JSON parse. Returns a plain JS object (not a Proxy). Pass an optional schema for type-safe validation.
|
|
573
557
|
|
|
574
558
|
With a schema, returns `DeepPartial<T>` — all properties are optional because incomplete JSON will have missing fields. When `safeParse` succeeds, returns validated `data`. When `safeParse` fails on a repaired-parse (partial JSON), the raw parsed value is kept — the object is partial, that's expected.
|
|
575
559
|
|
|
@@ -764,7 +748,7 @@ ANTHROPIC_API_KEY=sk-ant-... bun examples/anthropic-tool-call.ts
|
|
|
764
748
|
OPENAI_API_KEY=sk-... bun examples/openai-function-call.ts
|
|
765
749
|
```
|
|
766
750
|
|
|
767
|
-
See also `examples/ai-usage.ts` for additional patterns (MCP stdio,
|
|
751
|
+
See also `examples/ai-usage.ts` for additional patterns (MCP stdio, NDJSON embeddings).
|
|
768
752
|
|
|
769
753
|
## Building from Source
|
|
770
754
|
|