namespace FacebookService.Infrastructure.ExternalServices;

/// <summary>
/// EN: Interface for AI/LLM service client.
/// VI: Interface cho AI/LLM service client.
/// </summary>
public interface IAIClient
{
    /// <summary>
    /// EN: Generate a chat completion response.
    /// VI: Tạo response chat completion.
    /// </summary>
    Task<AICompletionResult> GenerateChatCompletionAsync(
        string systemPrompt,
        IEnumerable<ChatMessage> conversationHistory,
        AICompletionOptions options,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Check if the AI service is available.
    /// VI: Kiểm tra AI service có sẵn sàng không.
    /// </summary>
    Task<bool> IsAvailableAsync(CancellationToken cancellationToken = default);
}

#region Models

public record ChatMessage(
    string Role, // "user", "assistant", "system"
    string Content
);

public record AICompletionOptions(
    string Model,
    float Temperature = 0.7f,
    int MaxTokens = 500,
    float TopP = 1.0f,
    float FrequencyPenalty = 0.0f,
    float PresencePenalty = 0.0f
);

public record AICompletionResult(
    bool Success,
    string? Content = null,
    int? PromptTokens = null,
    int? CompletionTokens = null,
    string? Error = null,
    string? FinishReason = null
);

#endregion
