package tech.easyflow.ai.invoke.protocol.openai;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class OpenAiChatCompletionChunkResponse {

    private String id;
    private String object;
    private Long created;
    private String model;
    private List<Choice> choices;
    private OpenAiChatCompletionResponse.Usage usage;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getObject() {
        return object;
    }

    public void setObject(String object) {
        this.object = object;
    }

    public Long getCreated() {
        return created;
    }

    public void setCreated(Long created) {
        this.created = created;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public List<Choice> getChoices() {
        return choices;
    }

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

    public OpenAiChatCompletionResponse.Usage getUsage() {
        return usage;
    }

    public void setUsage(OpenAiChatCompletionResponse.Usage usage) {
        this.usage = usage;
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Choice {

        private Integer index;
        private Delta delta;
        @JSONField(name = "finish_reason")
        @JsonProperty("finish_reason")
        private String finishReason;

        public Integer getIndex() {
            return index;
        }

        public void setIndex(Integer index) {
            this.index = index;
        }

        public Delta getDelta() {
            return delta;
        }

        public void setDelta(Delta delta) {
            this.delta = delta;
        }

        public String getFinishReason() {
            return finishReason;
        }

        public void setFinishReason(String finishReason) {
            this.finishReason = finishReason;
        }
    }

    @JsonIgnoreProperties(ignoreUnknown = true)
    public static class Delta {

        private String role;
        private String content;
        @JSONField(name = "tool_calls")
        @JsonProperty("tool_calls")
        private List<OpenAiChatCompletionResponse.ToolCall> toolCalls;

        public String getRole() {
            return role;
        }

        public void setRole(String role) {
            this.role = role;
        }

        public String getContent() {
            return content;
        }

        public void setContent(String content) {
            this.content = content;
        }

        public List<OpenAiChatCompletionResponse.ToolCall> getToolCalls() {
            return toolCalls;
        }

        public void setToolCalls(List<OpenAiChatCompletionResponse.ToolCall> toolCalls) {
            this.toolCalls = toolCalls;
        }
    }
}
