UIMessageStreamExtensions
Namespace: Vercel.AI.AspNetCore
public static class UIMessageStreamExtensionsWrites a StreamTextResult as an AI SDK UI message stream.
Inheritance: object
Methods
Section titled “Methods”ToUIMessageStreamResult(StreamTextResult, int?, Func<string, string>?)
Section titled “ToUIMessageStreamResult(StreamTextResult, int?, Func<string, string>?)”public static IResult ToUIMessageStreamResult(this StreamTextResult result, int? keepAliveMs = null, Func<string, string>? onError = null)Returns a text/event-stream result a JavaScript useChat client can consume.
Emitted chunks are start, text, reasoning, tool input/output, tool approval request, source-url, step boundaries, finish, abort, and error.
Finish reasons use the protocol values stop, length, content-filter, tool-calls, error, and other.
Parameters
| Name | Type | Description |
|---|---|---|
result |
StreamTextResult | The stream to write. |
keepAliveMs |
int? | Optional idle interval, in milliseconds. Null sends no SSE comments. A positive value up to 2147483647 writes : stream-open before the start event and : keep-alive while the next part is still pending. |
onError |
Func<string, string> | Optional mapper for error chunk text. Null writes An error occurred.. Errors of provider-executed tools are not masked. |
Returns: IResult
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product