package com.lingyue.ai.dto;

import lombok.Data;

import java.util.List;

/**
 * DeepSeek Chat API 响应
 *
 * @author lingyue
 * @since 2026-01-15
 */
@Data
public class ChatResponse {

    /**
     * 响应ID
     */
    private String id;

    /**
     * 对象类型
     */
    private String object;

    /**
     * 创建时间戳
     */
    private Long created;

    /**
     * 使用的模型
     */
    private String model;

    /**
     * 选择列表
     */
    private List<Choice> choices;

    /**
     * Token 使用统计
     */
    private Usage usage;

    /**
     * 获取第一个回复内容
     */
    public String getFirstContent() {
        if (choices != null && !choices.isEmpty()) {
            Choice choice = choices.get(0);
            if (choice.getMessage() != null) {
                return choice.getMessage().getContent();
            }
        }
        return null;
    }

    @Data
    public static class Choice {
        private Integer index;
        private ChatMessage message;
        private String finish_reason;
    }

    @Data
    public static class Usage {
        private Integer prompt_tokens;
        private Integer completion_tokens;
        private Integer total_tokens;
    }
}
