Skip to content

ModelPartStream

Namespace: Vercel.AI.Operations

public sealed class ModelPartStream

Model stream that stays open until Cancel() when Completes is false.

Inheritance: object

View source

ModelPartStream(IReadOnlyList<ModelStreamPart>, bool, Exception?)

Section titled “ModelPartStream(IReadOnlyList<ModelStreamPart>, bool, Exception?)”
public ModelPartStream(IReadOnlyList<ModelStreamPart> parts, bool completes = true, Exception? failure = null)

Creates a scripted stream.

Parameters

Name Type Description
parts IReadOnlyList<ModelStreamPart>
completes bool
failure Exception

View source

public bool Cancelled { get; }

True after Cancel().

Value: bool

View source

public bool Completes { get; }

True when the stream ends after Parts.

Value: bool

View source

public Exception? Failure { get; }

Error raised after the scripted parts.

Value: Exception

View source

public IReadOnlyList<ModelStreamPart> Parts { get; }

Scripted parts.

Value: IReadOnlyList<ModelStreamPart>

View source

public void Cancel()

Stops a stream that has not completed.

View source

public IAsyncEnumerable<ModelStreamPart> ReadAsync(CancellationToken cancellationToken = default)

Reads the scripted parts, then waits when the stream stays open.

Parameters

Name Type Description
cancellationToken CancellationToken

Returns: IAsyncEnumerable<ModelStreamPart>

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product