using System.Collections.Generic;
using System.Text.Json.Serialization; // For System.Text.Json attributes

namespace iyixiGames.AI.DTOs.DeepSeek
{
    // --- 请求 DTOs ---

    /// <summary>
    /// DeepSeek API 的消息对象。
    /// </summary>
    public class DeepSeekMessage
    {
        [JsonPropertyName("role")]
        public string Role { get; set; } = string.Empty; // "user", "assistant", "system"

        [JsonPropertyName("content")]
        public string Content { get; set; } = string.Empty;
    }

    /// <summary>
    /// DeepSeek API 的聊天完成请求。
    /// </summary>
    public class DeepSeekChatCompletionRequest
    {
        [JsonPropertyName("model")]
        public string Model { get; set; } = string.Empty;

        [JsonPropertyName("messages")]
        public List<DeepSeekMessage> Messages { get; set; } = new List<DeepSeekMessage>();

        [JsonPropertyName("max_tokens")]
        public int? MaxTokens { get; set; } // 可选，最大生成 token 数

        [JsonPropertyName("temperature")]
        public double? Temperature { get; set; } // 可选，控制生成随机性
    }

    // --- 响应 DTOs ---

    /// <summary>
    /// DeepSeek API 的响应 Choice 对象。
    /// </summary>
    public class DeepSeekChoice
    {
        [JsonPropertyName("index")]
        public int Index { get; set; }

        [JsonPropertyName("message")]
        public DeepSeekMessage Message { get; set; } = new DeepSeekMessage();

        [JsonPropertyName("finish_reason")]
        public string FinishReason { get; set; } = string.Empty;
    }

    /// <summary>
    /// DeepSeek API 的聊天完成响应。
    /// </summary>
    public class DeepSeekChatCompletionResponse
    {
        [JsonPropertyName("id")]
        public string Id { get; set; } = string.Empty;

        [JsonPropertyName("object")]
        public string Object { get; set; } = string.Empty;

        [JsonPropertyName("created")]
        public long Created { get; set; }

        [JsonPropertyName("model")]
        public string Model { get; set; } = string.Empty;

        [JsonPropertyName("choices")]
        public List<DeepSeekChoice> Choices { get; set; } = new List<DeepSeekChoice>();

        [JsonPropertyName("usage")]
        public DeepSeekUsage? Usage { get; set; } // 可空
    }

    /// <summary>
    /// DeepSeek API 的使用情况统计。
    /// </summary>
    public class DeepSeekUsage
    {
        [JsonPropertyName("prompt_tokens")]
        public int PromptTokens { get; set; }

        [JsonPropertyName("completion_tokens")]
        public int CompletionTokens { get; set; }

        [JsonPropertyName("total_tokens")]
        public int TotalTokens { get; set; }
    }
}