package com.yaoai.ai.core.model;

import lombok.Data;

import java.util.List;

/** OpenAI-compatible chat completions response */
@Data
public class ChatResponse {

    private String id;
    private List<Choice> choices;
    private Usage usage;

    @Data
    public static class Choice {
        private int index;
        private ChatMessage message;
        @com.fasterxml.jackson.annotation.JsonProperty("finish_reason")
        private String finishReason;
    }

    @Data
    public static class Usage {
        @com.fasterxml.jackson.annotation.JsonProperty("prompt_tokens")
        private int promptTokens;
        @com.fasterxml.jackson.annotation.JsonProperty("completion_tokens")
        private int completionTokens;
        @com.fasterxml.jackson.annotation.JsonProperty("total_tokens")
        private int totalTokens;
    }

    public String firstContent() {
        if (choices == null || choices.isEmpty()) return "";
        ChatMessage msg = choices.get(0).getMessage();
        return msg != null ? msg.getContent() : "";
    }
}
