package org.xyzh.ai.client.dto;

import com.alibaba.fastjson2.annotation.JSONField;
import lombok.Data;

/**
 * @description 文档上传请求
 * @filename DocumentUploadRequest.java
 * @author AI Assistant
 * @copyright xyzh
 * @since 2025-11-04
 */
@Data
public class DocumentUploadRequest {

    /**
     * 文档名称
     */
    private String name;

    /**
     * 索引方式
     */
    @JSONField(name = "indexing_technique")
    private String indexingTechnique;

    /**
     * 处理规则
     */
    @JSONField(name = "process_rule")
    private ProcessRule processRule;

    @Data
    public static class ProcessRule {
        /**
         * 分段模式：automatic（自动）、custom（自定义）
         */
        private String mode = "automatic";

        /**
         * 预处理规则
         */
        private Rules rules;

        @Data
        public static class Rules {
            /**
             * 自动分段配置
             */
            @JSONField(name = "pre_processing_rules")
            private PreProcessingRules preProcessingRules;

            /**
             * 分段配置
             */
            private Segmentation segmentation;
        }

        @Data
        public static class PreProcessingRules {
            /**
             * 移除额外空格
             */
            @JSONField(name = "remove_extra_spaces")
            private Boolean removeExtraSpaces = true;

            /**
             * 移除URL和邮箱
             */
            @JSONField(name = "remove_urls_emails")
            private Boolean removeUrlsEmails = false;
        }

        @Data
        public static class Segmentation {
            /**
             * 分隔符
             */
            private String separator = "\\n";

            /**
             * 最大分段长度
             */
            @JSONField(name = "max_tokens")
            private Integer maxTokens = 1000;

            /**
             * 分段重叠长度
             */
            @JSONField(name = "chunk_overlap")
            private Integer chunkOverlap = 50;
        }
    }
}

