package org.xyzh.ai.client.dto;

import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;
import java.util.List;
import java.util.Map;

/**
 * @description 对话响应（阻塞模式）
 * @filename ChatResponse.java
 * @author AI Assistant
 * @copyright xyzh
 * @since 2025-11-04
 */
@Data
public class ChatResponse {

    /**
     * 消息ID
     */
    @JSONField(name = "message_id")
    private String messageId;

    /**
     * 对话ID
     */
    @JSONField(name = "conversation_id")
    private String conversationId;

    /**
     * 模式
     */
    private String mode;

    /**
     * 回答内容
     */
    private String answer;

    /**
     * 元数据
     */
    private Map<String, Object> metadata;

    /**
     * 创建时间
     */
    @JSONField(name = "created_at")
    private Long createdAt;

    /**
     * Token使用情况
     */
    private Usage usage;

    /**
     * 检索信息
     */
    @JSONField(name = "retrieval_info")
    private List<RetrievalInfo> retrievalInfo;

    @Data
    public static class Usage {
        @JSONField(name = "prompt_tokens")
        private Integer promptTokens;

        @JSONField(name = "prompt_unit_price")
        private String promptUnitPrice;

        @JSONField(name = "prompt_price_unit")
        private String promptPriceUnit;

        @JSONField(name = "prompt_price")
        private String promptPrice;

        @JSONField(name = "completion_tokens")
        private Integer completionTokens;

        @JSONField(name = "completion_unit_price")
        private String completionUnitPrice;

        @JSONField(name = "completion_price_unit")
        private String completionPriceUnit;

        @JSONField(name = "completion_price")
        private String completionPrice;

        @JSONField(name = "total_tokens")
        private Integer totalTokens;

        @JSONField(name = "total_price")
        private String totalPrice;

        private String currency;

        private Double latency;
    }

    @Data
    public static class RetrievalInfo {
        @JSONField(name = "dataset_id")
        private String datasetId;

        @JSONField(name = "dataset_name")
        private String datasetName;

        @JSONField(name = "document_id")
        private String documentId;

        @JSONField(name = "document_name")
        private String documentName;

        @JSONField(name = "segment_id")
        private String segmentId;

        private Double score;

        private String content;
    }
}

