Table of Contents

Method StreamAsync

Namespace
LMKit.Agents.Orchestration.Streaming
Assembly
LM-Kit.NET.dll

StreamAsync(IOrchestrator, string, OrchestrationOptions, CancellationToken)

Streams orchestration output as an async enumerable.

public static IAsyncEnumerable<OrchestrationStreamToken> StreamAsync(this IOrchestrator orchestrator, string input, OrchestrationOptions options = null, CancellationToken cancellationToken = default)

Parameters

orchestrator IOrchestrator

The orchestrator to execute.

input string

The input prompt.

options OrchestrationOptions

Optional orchestration options.

cancellationToken CancellationToken

Cancellation token.

Returns

IAsyncEnumerable<OrchestrationStreamToken>

An async enumerable of streaming tokens.

Examples

await foreach (var token in orchestrator.StreamAsync("Build an API"))
{
    switch (token.Type)
    {
        case OrchestrationStreamTokenType.Content:
            Console.Write(token.Text);
            break;
        case OrchestrationStreamTokenType.AgentStarted:
            Console.WriteLine($"\n--- {token.AgentName} ---");
            break;
    }
}
Share