LanguageModelStreamResult
Namespace: Vercel.AI.Provider
public sealed class LanguageModelStreamResult : IAsyncEnumerable<LanguageModelStreamPart>, IAsyncDisposable, IDisposableWhat CancellationToken) returns: the stream plus the request and response info.
Maps to the { stream, request, response } object returned by doStream.
Enumerating the result enumerates Stream.
A provider opens the HTTP response in DoStreamAsync. Dispose the result to release that response when you stop without enumerating the stream, or while you enumerate it.
Disposing is safe to repeat, and it does nothing after the stream has ended.
Inheritance: object
Implements: IAsyncEnumerable<LanguageModelStreamPart>, IAsyncDisposable, IDisposable
Constructors
Section titled “Constructors”LanguageModelStreamResult(IAsyncEnumerable<LanguageModelStreamPart>, LanguageModelStreamRequest?, LanguageModelStreamResponse?, IDisposable?)
Section titled “LanguageModelStreamResult(IAsyncEnumerable<LanguageModelStreamPart>, LanguageModelStreamRequest?, LanguageModelStreamResponse?, IDisposable?)”public LanguageModelStreamResult(IAsyncEnumerable<LanguageModelStreamPart> stream, LanguageModelStreamRequest? request = null, LanguageModelStreamResponse? response = null, IDisposable? resource = null)Creates a stream result.
Parameters
| Name | Type | Description |
|---|---|---|
stream |
IAsyncEnumerable<LanguageModelStreamPart> | The stream parts. |
request |
LanguageModelStreamRequest | Request info. |
response |
LanguageModelStreamResponse | Response info. |
resource |
IDisposable | A resource the provider opened for the stream, such as the HTTP response. The result disposes it once. |
Properties
Section titled “Properties”Request
Section titled “Request”public LanguageModelStreamRequest? Request { get; }Request info, when the model reports it.
Value: LanguageModelStreamRequest
Response
Section titled “Response”public LanguageModelStreamResponse? Response { get; }Response info, when the model reports it.
Value: LanguageModelStreamResponse
Stream
Section titled “Stream”public IAsyncEnumerable<LanguageModelStreamPart> Stream { get; }The stream parts.
Value: IAsyncEnumerable<LanguageModelStreamPart>
Methods
Section titled “Methods”ConfigureAwait(bool)
Section titled “ConfigureAwait(bool)”public ConfiguredCancelableAsyncEnumerable<LanguageModelStreamPart> ConfigureAwait(bool continueOnCapturedContext)Configures how awaits on the stream parts run. This instance method keeps await foreach (var part in result.ConfigureAwait(false))
unambiguous, because the result is both an async enumerable and an async disposable.
Parameters
| Name | Type | Description |
|---|---|---|
continueOnCapturedContext |
bool |
Returns: ConfiguredCancelableAsyncEnumerable<LanguageModelStreamPart>
Dispose()
Section titled “Dispose()”public void Dispose()Releases the resource the provider opened for this stream. Safe to call more than once.
DisposeAsync()
Section titled “DisposeAsync()”public ValueTask DisposeAsync()Releases the resource the provider opened for this stream. Safe to call more than once.
Returns: ValueTask
GetAsyncEnumerator(CancellationToken)
Section titled “GetAsyncEnumerator(CancellationToken)”public IAsyncEnumerator<LanguageModelStreamPart> GetAsyncEnumerator(CancellationToken cancellationToken = default)Returns an enumerator that iterates asynchronously through the collection.
Parameters
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken | A CancellationToken that may be used to cancel the asynchronous iteration. |
Returns: IAsyncEnumerator<LanguageModelStreamPart> — An enumerator that can be used to iterate asynchronously through the collection.
Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product