////#r "nuget: Azure.AI.OpenAI"
////#r "nuget:  Microsoft.Agents.AI.OpenAI, *-*"
////#r "nuget: Microsoft.Agents.AI.Workflows, *-*"

//using Microsoft.Agents.AI;
//using Azure.AI.OpenAI;
//using System.ClientModel;
//using OpenAI;
//using System.ComponentModel;
//using Microsoft.Extensions.AI;
//using System.Text.Json;

//public static class MafHelper
//{
//    public static AzureOpenAIClient GetAzureOpenAIClient()
//    {
//        var endpoint = new Uri("https://my-openapi.openai.azure.com");
//        var apiKey = "D6uw9hVI6vXTjGo35RTlEpTWbhfXd8xRs38tG2gIgWtvhNpxjJt4JQQJ99BDACYeBjFXJ3w3AAABACOGvPWE";

//        var clientOptions = new AzureOpenAIClientOptions()
//        {
//            // Version = AzureOpenAIClientOptions.ServiceVersion.V2024_12_01_preview
//        };
//        var azureClient = new AzureOpenAIClient(
//            endpoint: endpoint,
//            credential: new ApiKeyCredential(apiKey),
//            options: clientOptions
//        );

//        return azureClient;
//    }

//    [Description("The current datetime offset.")]
//    public static string GetDateTime() => DateTimeOffset.Now.ToString();

//    /// <summary>
//    /// 创建一个默认的 Agent，包含当前时间工具
//    /// </summary>
//    /// <param name="modelName"></param>
//    /// <returns></returns>
//    public static AIAgent GetDefaultAgent(string modelName = "gpt-4o")
//    {
//        var azureClient = GetAzureOpenAIClient();
//        var chatClient = azureClient.GetChatClient(modelName);

//        var agent = chatClient.CreateAIAgent(
//            name: "DefaultAgent",
//            instructions: "你是一名得力的助手。",
//            tools: [AIFunctionFactory.Create(GetDateTime, name: nameof(GetDateTime))]
//        );

//        return agent;
//    }



//    public static AIAgent GetAgentInJsonSchemaResponse(JsonElement jsonSchema, string modelName = "gpt-4o")
//    {
//        var azureClient = GetAzureOpenAIClient();
//        var chatClient = azureClient.GetChatClient(modelName);

//        ChatOptions chatOptions = new()
//        {
//            // Tools = [AIFunctionFactory.Create(GetDateTime, name: nameof(GetDateTime))],
//            ResponseFormat = ChatResponseFormatJson.ForJsonSchema(schema: jsonSchema)
//        };

//        var agent = chatClient.CreateAIAgent(
//            options: new ChatClientAgentOptions()
//            {
//                Name = "HelperAgent",
//                Instructions = "你是一个乐于助人的助手。",
//                ChatOptions = chatOptions
//            });

//        return agent;
//    }


//    public static AIAgent GetAgentInJsonResponse(string modelName = "gpt-4o")
//    {
//        var azureClient = GetAzureOpenAIClient();
//        var chatClient = azureClient.GetChatClient(modelName);
//        ChatOptions chatOptions = new()
//        {
//            ResponseFormat = ChatResponseFormat.Json,
//            Tools = [AIFunctionFactory.Create(GetDateTime, name: nameof(GetDateTime))]
//        };

//        var agent = chatClient.CreateAIAgent(
//            options: new ChatClientAgentOptions()
//            {
//                Name = "HelperAgent",
//                Instructions = "你是一个乐于助人的助手，所有的回答都必须是JSON格式。",
//                ChatOptions = chatOptions
//            });

//        return agent;
//    }
//}