package com.ruoyi.llm.domain;

/**
 * 回答流式响应
 */
public class AnswerStreamResponse {

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

    /**
     * 是否是最后一块内容
     */
    private boolean isLast;

    /**
     * 是否发生错误
     */
    private boolean error;

    /**
     * 错误信息
     */
    private String errorMessage;

    /**
     * 提示词token数量
     */
    private long promptTokens;

    /**
     * 完成token数量
     */
    private long completionTokens;

    /**
     * 总token数量
     */
    private long totalTokens;

    public AnswerStreamResponse() {
    }

    /**
     * 创建内容响应
     */
    public static AnswerStreamResponse content(String content, boolean isLast) {
        AnswerStreamResponse response = new AnswerStreamResponse();
        response.content = content;
        response.isLast = isLast;
        response.error = false;
        return response;
    }

    /**
     * 创建错误响应
     */
    public static AnswerStreamResponse error(String errorMessage) {
        AnswerStreamResponse response = new AnswerStreamResponse();
        response.error = true;
        response.errorMessage = errorMessage;
        return response;
    }

    // Getters and Setters
    public String getContent() {
        return content;
    }

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

    public boolean isLast() {
        return isLast;
    }

    public void setLast(boolean last) {
        isLast = last;
    }

    public boolean isError() {
        return error;
    }

    public void setError(boolean error) {
        this.error = error;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public long getPromptTokens() {
        return promptTokens;
    }

    public void setPromptTokens(long promptTokens) {
        this.promptTokens = promptTokens;
    }

    public long getCompletionTokens() {
        return completionTokens;
    }

    public void setCompletionTokens(long completionTokens) {
        this.completionTokens = completionTokens;
    }

    public long getTotalTokens() {
        return totalTokens;
    }

    public void setTotalTokens(long totalTokens) {
        this.totalTokens = totalTokens;
    }
}