ChatCompletionSyncResponse.java 1.3 KB
Newer Older
M
maxuan 已提交
1 2 3 4 5 6 7 8
package cn.bugstack.chatglm.model;

import lombok.Data;

import java.util.List;

/**
 * 同步调用响应
9
 *
M
maxuan 已提交
10 11 12 13 14 15 16 17 18 19 20
 * @author max
 * @date 2023/12/14 15:41
 */
@Data
public class ChatCompletionSyncResponse {

    private Integer code;
    private String msg;
    private Boolean success;
    private ChatGLMData data;

21 22 23 24 25 26 27 28 29 30 31
    // 24年1月发布模型新增字段 GLM3、GLM4
    private String task_status;
    private List<Choice> choices;

    public void setChoices(List<Choice> choices) {
        this.choices = choices;
        this.data = new ChatGLMData();
        this.data.setChoices(choices);
    }


M
maxuan 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    @Data
    public static class ChatGLMData {
        private List<Choice> choices;
        private String task_status;
        private Usage usage;
        private String task_id;
        private String request_id;
    }

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

    @Data
    public static class Choice {
50 51 52 53 54 55 56 57 58 59 60 61

        private String role;
        private String content;

        // 24年1月发布模型新增字段 GLM3、GLM4
        private String finish_reason;
        private int index;
        private Message message;
    }

    @Data
    public static class Message {
M
maxuan 已提交
62 63 64 65 66
        private String role;
        private String content;
    }

}