package top.tqx.demo_1.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Data
public class RagRequest implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @JsonProperty("message")
    private String message;
    
    @JsonProperty("collections")
    private List<String> collections;
    
    @JsonProperty("session_id")
    private String sessionId;
    
    @JsonProperty("history")
    private List<HistoryItem> history;
    
    @JsonProperty("id")
    private String id;
    
    @JsonIgnore
    private Long userId;
    
    @JsonIgnore
    private Long deptId;
    
    @JsonIgnore
    private Integer userRole;
    
    @Data
    public static class HistoryItem {
        private String role;
        private String content;
    }
    
    @JsonProperty("inputs")
    public Map<String, Object> getInputs() {
        Map<String, Object> inputs = new HashMap<>();
        inputs.put("ques", message != null ? message : "");
        inputs.put("id", userId != null ? userId.toString() : "");
        inputs.put("role", userRole != null ? userRole.toString() : "");
        inputs.put("dep", deptId != null ? deptId.toString() : "");
        return inputs;
    }
}