Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New
experimental_streamUI()
API (#1379)
- Loading branch information
Showing
8 changed files
with
683 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'ai': patch | ||
--- | ||
|
||
ai/rsc: add experimental_streamUI() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 185 additions & 0 deletions
185
packages/core/rsc/stream-ui/__snapshots__/stream-ui.ui.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`result.value > should render text 1`] = ` | ||
{ | ||
"children": { | ||
"children": {}, | ||
"props": { | ||
"c": undefined, | ||
"n": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": true, | ||
"value": "{ \\"content\\": \\"Hello, world!\\" }", | ||
}, | ||
"value": "{ \\"content\\": \\"Hello, world!\\" }", | ||
}, | ||
"value": "{ \\"content\\": \\"Hello, world!\\"", | ||
}, | ||
"value": "{ \\"content\\": \\"Hello, world", | ||
}, | ||
"value": "{ \\"content\\": \\"Hello, ", | ||
}, | ||
"value": "{ \\"content\\": ", | ||
}, | ||
"value": "{ ", | ||
}, | ||
}, | ||
"type": "", | ||
}, | ||
"props": { | ||
"fallback": undefined, | ||
}, | ||
"type": "Symbol(react.suspense)", | ||
} | ||
`; | ||
|
||
exports[`result.value > should render text function returned ui 1`] = ` | ||
{ | ||
"children": { | ||
"children": {}, | ||
"props": { | ||
"c": undefined, | ||
"n": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": true, | ||
"value": <h1> | ||
{ "content": "Hello, world!" } | ||
</h1>, | ||
}, | ||
"value": <h1> | ||
{ "content": "Hello, world!" } | ||
</h1>, | ||
}, | ||
"value": <h1> | ||
{ "content": "Hello, world!" } | ||
</h1>, | ||
}, | ||
"value": <h1> | ||
{ "content": "Hello, world!" | ||
</h1>, | ||
}, | ||
"value": <h1> | ||
{ "content": "Hello, world | ||
</h1>, | ||
}, | ||
"value": <h1> | ||
{ "content": "Hello, | ||
</h1>, | ||
}, | ||
"value": <h1> | ||
{ "content": | ||
</h1>, | ||
}, | ||
"value": <h1> | ||
{ | ||
</h1>, | ||
}, | ||
}, | ||
"type": "", | ||
}, | ||
"props": { | ||
"fallback": undefined, | ||
}, | ||
"type": "Symbol(react.suspense)", | ||
} | ||
`; | ||
exports[`result.value > should render tool call results 1`] = ` | ||
{ | ||
"children": { | ||
"children": {}, | ||
"props": { | ||
"c": undefined, | ||
"n": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": true, | ||
"value": <div> | ||
tool1: | ||
value | ||
</div>, | ||
}, | ||
"value": <div> | ||
tool1: | ||
value | ||
</div>, | ||
}, | ||
"value": "", | ||
}, | ||
}, | ||
"type": "", | ||
}, | ||
"props": { | ||
"fallback": undefined, | ||
}, | ||
"type": "Symbol(react.suspense)", | ||
} | ||
`; | ||
exports[`result.value > should render tool call results with generator render function 1`] = ` | ||
{ | ||
"children": { | ||
"children": {}, | ||
"props": { | ||
"c": undefined, | ||
"n": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": false, | ||
"next": { | ||
"done": true, | ||
"value": <div> | ||
tool: | ||
value | ||
</div>, | ||
}, | ||
"value": <div> | ||
tool: | ||
value | ||
</div>, | ||
}, | ||
"value": "", | ||
}, | ||
"value": <div> | ||
Loading... | ||
</div>, | ||
}, | ||
}, | ||
"type": "", | ||
}, | ||
"props": { | ||
"fallback": undefined, | ||
}, | ||
"type": "Symbol(react.suspense)", | ||
} | ||
`; | ||
exports[`result.value > should show better error messages if legacy options are passed 1`] = `[Error: Tool definition in \`experimental_streamUI\` should not have \`render\` property. Use \`generate\` instead. Found in tool: tool1]`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { experimental_streamUI } from './stream-ui'; |
Oops, something went wrong.