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
orchestratorIOrchestratorThe orchestrator to execute.
inputstringThe input prompt.
optionsOrchestrationOptionsOptional orchestration options.
cancellationTokenCancellationTokenCancellation 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;
}
}