// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using System.Text.Json; using System.Text.Json.Serialization; namespace Microsoft.Teams.AI.Messages; [Obsolete("Microsoft.Teams.AI is deprecated and will be removed by end of summer 2026.")] public class ModelMessage(object? content) : ModelMessage(content) { public static ModelMessage Text(string content) => new(content); public static ModelMessage> Text(IEnumerable content) => new(content); public static ModelMessage Media(Stream content) => new(content); } [Obsolete("Microsoft.Teams.AI is deprecated and will be removed by end of summer 2026.")] public class ModelMessage : IMessage { [JsonPropertyName("role")] [JsonPropertyOrder(0)] public Role Role => Role.Model; [JsonPropertyName("content")] [JsonPropertyOrder(1)] public T Content { get; set; } [JsonPropertyName("function_calls")] [JsonPropertyOrder(2)] public IList? FunctionCalls { get; set; } [JsonIgnore] public bool HasFunctionCalls => FunctionCalls is not null && FunctionCalls.Count > 0; [JsonConstructor] public ModelMessage(T content, IList? functionCalls = null) { Content = content; FunctionCalls = functionCalls; } public override string ToString() { return JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull }); } } /// /// represents a models request to /// invoke a function /// [Obsolete("Microsoft.Teams.AI is deprecated and will be removed by end of summer 2026.")] public class FunctionCall { [JsonPropertyName("id")] [JsonPropertyOrder(0)] public required string Id { get; set; } [JsonPropertyName("name")] [JsonPropertyOrder(1)] public required string Name { get; set; } [JsonPropertyName("arguments")] [JsonPropertyOrder(2)] public string? Arguments { get; set; } public IDictionary? Parse() { return JsonSerializer.Deserialize>(Arguments ?? "{}"); } public override string ToString() { return JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull }); } }