Skip to content

Commit f7e8bf4

Browse files
authored
chore (ai): flatten ui message stream parts (#6332)
## Background The UI message stream parts had an unnecessary `value` nesting that decreases readability and increases data transfer. ## Summary Remove the `value` nesting. ## Verification Tested using `examples/next-openai`. Verified in EventStream chrome dev tool.
1 parent ed675de commit f7e8bf4

26 files changed

+766
-941
lines changed

‎.changeset/light-books-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ai': major
3+
---
4+
5+
chore (ai): flatten ui message stream parts

‎examples/next-openai/app/api/use-chat-custom-sources/route.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ export async function POST(req: Request) {
1414
// write a custom url source to the stream:
1515
writer.write({
1616
type: 'source',
17-
value: {
18-
sourceType: 'url',
19-
id: 'source-1',
20-
url: 'https://example.com',
21-
title: 'Example Source',
22-
},
17+
sourceType: 'url',
18+
id: 'source-1',
19+
url: 'https://example.com',
20+
title: 'Example Source',
2321
});
2422

2523
const result = streamText({

‎examples/next-openai/app/api/use-chat-human-in-the-loop/utils.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ export async function processToolCalls<
9999
// Forward updated tool result to the client.
100100
dataStream.write({
101101
type: 'tool-result',
102-
value: {
103-
toolCallId: toolInvocation.toolCallId,
104-
result,
105-
},
102+
toolCallId: toolInvocation.toolCallId,
103+
result,
106104
});
107105

108106
// Return updated toolInvocation with the actual result.

0 commit comments

Comments
 (0)