// Copyright (c) Microsoft. All rights reserved.

using System.ClientModel;
using System.ClientModel.Primitives;
using Microsoft.SemanticKernel.Agents.OpenAI;
using OpenAI;
using OpenAI.Files;
using OpenAI.Responses;
using OpenAI.VectorStores;

/// <summary>
/// Base class for samples that demonstrate the usage of <see cref="OpenAIResponseAgent"/>.
/// </summary>
public abstract class BaseResponsesAgentTest : BaseAgentsTest<ResponsesClient>
{
    protected BaseResponsesAgentTest(ITestOutputHelper output, string? model = null) : base(output)
    {
        var options = new OpenAIClientOptions();
        if (this.EnableLogging)
        {
            options.MessageLoggingPolicy = new MessageLoggingPolicy(new()
            {
                EnableLogging = true,
                EnableMessageLogging = true,
                EnableMessageContentLogging = true,
                LoggerFactory = this.LoggerFactory
            });
        }

        this.ModelId = model ?? TestConfiguration.OpenAI.ChatModelId;
        this.Client = new(credential: new ApiKeyCredential(TestConfiguration.OpenAI.ApiKey), options: options);
        this.FileClient = new OpenAIFileClient(TestConfiguration.OpenAI.ApiKey);
        this.VectorStoreClient = new VectorStoreClient(TestConfiguration.OpenAI.ApiKey);
    }

    protected string ModelId { get; set; }

    protected OpenAIFileClient FileClient { get; set; }

    protected VectorStoreClient VectorStoreClient { get; set; }

    protected bool EnableLogging { get; set; } = false;

    /// <inheritdoc/>
    protected override ResponsesClient Client { get; }
}
