package cn.teammodel.ai.domain;

import lombok.Data;

import java.util.List;

/**
 * spark ws 的响应实体
 * @Author: winter
 */
@Data
public class SparkChatResponse {
    private Header header;
    private Payload payload;

    @Data
    public static class Header{
        /**
        * 错误码，0表示正常，非0表示出错
        */
        private Integer code;
        private String message;
        private String sid;
        /**
         * 会话状态，取值为[0,1,2]；0代表首次结果；1代表中间结果；2代表最后一个结果
         */
        private Integer status;
    }

    @Data
    public static class Payload{
        private Choices choices;
        private Usage usage;
    }

    @Data
    public static class Choices{
        private Integer status;
        private Integer seq;
        private List<Text> text;
    }

    @Data
    public static class Usage{
        private UsageText text;
    }
    @Data
    public static class UsageText{
        private Integer question_tokens;
        /**
         * 包含历史问题的总tokens大小
         */
        private Integer prompt_tokens;
        /**
         * 回答的tokens大小
         */
        private Integer completion_tokens;
        /**
         * prompt_tokens和completion_tokens的和，也是本次交互计费的tokens大小
         */
        private Integer total_tokens;
    }

    @Data
    public static class Text{
        /**
         * AI的回答内容
         */
        private String content;
        /**
         * 角色标识，固定为assistant，标识角色为AI
         */
        private String role;
        private Integer index;
    }

}
