mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
e413c5a285
* Add M365 Agent SDK interop sample * Update dotnet/samples/M365Agent/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Address some comments. * Update dotnet/samples/M365Agent/Agents/WeatherForecastAgent.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dotnet/samples/M365Agent/Agents/WeatherForecastAgentResponse.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update dotnet/samples/M365Agent/Agents/WeatherForecastAgentResponse.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Address PR comments * Refactor code to simplify. * Fix broken link. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
// Copyright (c) Microsoft. All rights reserved.
|
|
|
|
using System.Text.Json.Serialization;
|
|
using AdaptiveCards;
|
|
using Microsoft.Agents.AI;
|
|
using Microsoft.Extensions.AI;
|
|
|
|
namespace M365Agent.Agents;
|
|
|
|
/// <summary>
|
|
/// An <see cref="AIContent"/> type allows an <see cref="AIAgent"/> to return adaptive cards as part of its response messages.
|
|
/// </summary>
|
|
internal sealed class AdaptiveCardAIContent : AIContent
|
|
{
|
|
public AdaptiveCardAIContent(AdaptiveCard adaptiveCard)
|
|
{
|
|
this.AdaptiveCard = adaptiveCard ?? throw new ArgumentNullException(nameof(adaptiveCard));
|
|
}
|
|
|
|
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
|
|
[JsonConstructor]
|
|
public AdaptiveCardAIContent(string adaptiveCardJson)
|
|
{
|
|
this.AdaptiveCardJson = adaptiveCardJson;
|
|
}
|
|
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
|
|
|
|
[JsonIgnore]
|
|
public AdaptiveCard AdaptiveCard { get; private set; }
|
|
|
|
public string AdaptiveCardJson
|
|
{
|
|
get => this.AdaptiveCard.ToJson();
|
|
set => this.AdaptiveCard = AdaptiveCard.FromJson(value).Card;
|
|
}
|
|
}
|