Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

ChunkStrategy.md

58 lines1.1 KB

1---
2id: ChunkStrategy
3title: ChunkStrategy
4---
5​
6# Interface: ChunkStrategy
7​
8Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:38](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L38)
9​
10Strategy for determining when to emit text updates
11​
12## Properties
13​
14### reset()?
15​
16```ts
17optional reset: () => void;
18```
19​
20Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:50](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L50)
21​
22Optional: Reset strategy state (called when streaming starts)
23​
24#### Returns
25​
26`void`
27​
28***
29​
30### shouldEmit()
31​
32```ts
33shouldEmit: (chunk, accumulated) => boolean;
34```
35​
36Defined in: [packages/typescript/ai/src/activities/chat/stream/types.ts:45](https://github.com/TanStack/ai/blob/main/packages/typescript/ai/src/activities/chat/stream/types.ts#L45)
37​
38Called for each text chunk received
39​
40#### Parameters
41​
42##### chunk
43​
44`string`
45​
46The new chunk of text (delta)
47​
48##### accumulated
49​
50`string`
51​
52All text accumulated so far
53​
54#### Returns
55​
56`boolean`
57​
58true if an update should be emitted now