Class DelegateOrchestrationStreamHandler
- Namespace
- LMKit.Agents.Orchestration.Streaming
- Assembly
- LM-Kit.NET.dll
A stream handler that delegates to callback functions.
Provides a simple way to handle orchestration streaming without implementing the full interface.
public sealed class DelegateOrchestrationStreamHandler : IOrchestrationStreamHandler
- Inheritance
-
DelegateOrchestrationStreamHandler
- Implements
- Inherited Members
Examples
// Simple token callback
var handler = new DelegateOrchestrationStreamHandler(
onToken: token => Console.Write(token.Text));
// With agent change notifications
var handler = new DelegateOrchestrationStreamHandler(
onToken: token =>
{
if (token.Type == OrchestrationStreamTokenType.Content)
Console.Write(token.Text);
else if (token.Type == OrchestrationStreamTokenType.AgentStarted)
Console.WriteLine($"\n[{token.AgentName}]");
});
await orchestrator.RunStreamingAsync("Task", handler);
Constructors
- DelegateOrchestrationStreamHandler(Action<OrchestrationStreamToken>, Action<IOrchestrator, string>, Action<OrchestrationResult>, Action<Exception>)
Initializes a new instance with synchronous callbacks.
- DelegateOrchestrationStreamHandler(Func<OrchestrationStreamToken, CancellationToken, Task>, Func<IOrchestrator, string, CancellationToken, Task>, Func<OrchestrationResult, CancellationToken, Task>, Func<Exception, CancellationToken, Task>)
Initializes a new instance with async callbacks.
Methods
- Console()
Creates a handler that writes content tokens to the console.
- ConsoleVerbose()
Creates a handler that writes all tokens to the console with detailed information.
- ConsoleWithAgentLabels()
Creates a handler that writes content tokens to the console with agent labels.
- OnErrorAsync(Exception, CancellationToken)
Called when an error occurs during the orchestration.
- OnOrchestrationCompleteAsync(OrchestrationResult, CancellationToken)
Called when the orchestration completes.
- OnOrchestrationStartAsync(IOrchestrator, string, CancellationToken)
Called when the orchestration starts.
- OnTokenAsync(OrchestrationStreamToken, CancellationToken)
Called when a new token is received from any agent in the orchestration.