AI-Studio/app/MindWork AI Studio/Tools/ToolCallingSystem/Harness/ToolCallingStreamEvent.cs
Thorsten Sommer c95cc5bacc
Some checks are pending
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Stream the answers again whenever tools are in play (#986)
2026-09-20 10:44:33 +02:00

36 lines
1.8 KiB
C#

using AIStudio.Provider;
namespace AIStudio.Tools.ToolCallingSystem.Harness;
/// <summary>
/// One event of a streamed round of a tool calling conversation.
/// </summary>
/// <remarks>
/// Text arrives while the round is still running, its outcome only at the end. A round which ends
/// without a ROUND_COMPLETED event has failed: that is how a failed request or a truncated stream
/// is told apart from a round which simply had nothing to say. The adapter has already told the
/// user what went wrong in that case, so the loop ends without a message of its own.
/// </remarks>
/// <param name="Kind">What this event carries.</param>
/// <param name="Delta">The piece of text, set for TEXT_DELTA events only.</param>
/// <param name="Round">The round's outcome, set for ROUND_COMPLETED events only.</param>
public sealed record ToolCallingStreamEvent(ToolCallingStreamEventKind Kind, ContentStreamChunk? Delta, ToolCallingRound? Round)
{
/// <summary>
/// Creates an event for a piece of text, along with the sources it brought.
/// </summary>
/// <param name="delta">The chunk to show.</param>
public static ToolCallingStreamEvent TextDelta(ContentStreamChunk delta) => new(ToolCallingStreamEventKind.TEXT_DELTA, delta, null);
/// <summary>
/// Creates an event for a piece of text without any sources.
/// </summary>
/// <param name="text">The text to show.</param>
public static ToolCallingStreamEvent TextDelta(string text) => new(ToolCallingStreamEventKind.TEXT_DELTA, new ContentStreamChunk(text, []), null);
/// <summary>
/// Creates the event which ends a round.
/// </summary>
/// <param name="round">The round's outcome.</param>
public static ToolCallingStreamEvent RoundCompleted(ToolCallingRound round) => new(ToolCallingStreamEventKind.ROUND_COMPLETED, null, round);
}