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

ChunkStrategy.md

56 lines1.0 KB

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