mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
* Checkpoint * Checkpoint * Namespaces * Namespace * Cleanup * Namespace order * Fix sync * Formatting * Formatting * Namespace * Namespace order * Code convention * Naming * Naming * Text handling * Text handling * Namespace * Namespace order * Namespace ordering * Test * ValueTask * net472 * Test fix * Fix namespace (net472) * Namespace * Fix conditional namespace * Fix type expression * Compatibility and cleanup * Sample compatibility * Sample compat * Test compat * modifier order * Simply http-stub * Formating fix for unit-test * Fix test * Real fix * Test clean-up * Update dotnet/src/Microsoft.Agents.Orchestration/Handoff/HandoffOrchestration.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix build errors after merging --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Stephen Toub <stoub@microsoft.com>
86 lines
2.6 KiB
C#
86 lines
2.6 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.AI;
|
|
|
|
namespace Microsoft.Agents.Orchestration.GroupChat;
|
|
|
|
/// <summary>
|
|
/// Common messages used for agent chat patterns.
|
|
/// </summary>
|
|
public static class GroupChatMessages
|
|
{
|
|
/// <summary>
|
|
/// An empty message instance as a default.
|
|
/// </summary>
|
|
internal static readonly ChatMessage Empty = new();
|
|
|
|
/// <summary>
|
|
/// Broadcast a message to all <see cref="GroupChatAgentActor"/>.
|
|
/// </summary>
|
|
public sealed class Group
|
|
{
|
|
/// <summary>
|
|
/// The chat message being broadcast.
|
|
/// </summary>
|
|
public IEnumerable<ChatMessage> Messages { get; init; } = [];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset/clear the conversation history for all <see cref="GroupChatAgentActor"/>.
|
|
/// </summary>
|
|
public sealed class Reset;
|
|
|
|
/// <summary>
|
|
/// The final result.
|
|
/// </summary>
|
|
public sealed class Result
|
|
{
|
|
/// <summary>
|
|
/// The chat response message.
|
|
/// </summary>
|
|
public ChatMessage Message { get; init; } = Empty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Signal a <see cref="GroupChatAgentActor"/> to respond.
|
|
/// </summary>
|
|
public sealed class Speak;
|
|
|
|
/// <summary>
|
|
/// The input task.
|
|
/// </summary>
|
|
public sealed class InputTask
|
|
{
|
|
/// <summary>
|
|
/// A task that does not require any action.
|
|
/// </summary>
|
|
public static readonly InputTask None = new();
|
|
|
|
/// <summary>
|
|
/// The input that defines the task goal.
|
|
/// </summary>
|
|
public IEnumerable<ChatMessage> Messages { get; init; } = [];
|
|
}
|
|
|
|
/// <summary>
|
|
/// Extension method to convert a <see cref="ChatMessage"/> to a <see cref="Group"/>.
|
|
/// </summary>
|
|
public static Group AsGroupMessage(this ChatMessage message) => new() { Messages = [message] };
|
|
|
|
/// <summary>
|
|
/// Extension method to convert a <see cref="ChatMessage"/> to a <see cref="Group"/>.
|
|
/// </summary>
|
|
public static Group AsGroupMessage(this IEnumerable<ChatMessage> messages) => new() { Messages = messages };
|
|
|
|
/// <summary>
|
|
/// Extension method to convert a <see cref="ChatMessage"/> to a <see cref="Result"/>.
|
|
/// </summary>
|
|
public static InputTask AsInputTaskMessage(this IEnumerable<ChatMessage> messages) => new() { Messages = messages };
|
|
|
|
/// <summary>
|
|
/// Extension method to convert a <see cref="ChatMessage"/> to a <see cref="Result"/>.
|
|
/// </summary>
|
|
public static Result AsResultMessage(this string text) => new() { Message = new(ChatRole.Assistant, text) };
|
|
}
|