diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/DocumentDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/DocumentDTO.java deleted file mode 100644 index 44b80582..00000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/DocumentDTO.java +++ /dev/null @@ -1,68 +0,0 @@ -package xiaozhi.modules.knowledge.dto; - -import java.io.Serializable; -import java.util.Date; -import java.util.Map; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 文档 DTO - */ -@Data -@Schema(description = "知识库文档") -public class DocumentDTO implements Serializable { - private static final long serialVersionUID = 1L; - - @Schema(description = "本地ID") - private String id; - - @Schema(description = "知识库ID") - private String datasetId; - - @Schema(description = "RAGFlow文档ID") - private String documentId; - - @Schema(description = "文档名称") - private String name; - - @Schema(description = "文件大小") - private Long size; - - @Schema(description = "文件类型") - private String type; - - @Schema(description = "分块方法") - private String chunkMethod; - - @Schema(description = "解析配置") - private Map parserConfig; - - @Schema(description = "处理状态 (1:解析中 3:成功 4:失败)") - private Integer status; - - @Schema(description = "错误信息") - private String error; - - @Schema(description = "分块数量") - private Integer chunkCount; - - @Schema(description = "Token数量") - private Long tokenCount; - - @Schema(description = "是否启用") - private Integer enabled; - - @Schema(description = "创建时间") - private Date createdAt; - - @Schema(description = "更新时间") - private Date updatedAt; - - @Schema(description = "上传进度 (虚拟字段)") - private Double progress; - - @Schema(description = "缩略图/预览图 (虚拟字段)") - private String thumbnail; -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/agent/AgentDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/agent/AgentDTO.java deleted file mode 100644 index 171e981a..00000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/agent/AgentDTO.java +++ /dev/null @@ -1,421 +0,0 @@ -package xiaozhi.modules.knowledge.dto.agent; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.*; - -@Schema(description = "智能体 (Agent) 管理聚合 DTO") -public class AgentDTO { - - // ========== 1. Agent 管理 (CRUD) - 对应 RAGFlow_Agent接口详解 ========== - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Agent 创建请求") - public static class CreateReq implements Serializable { - @Schema(description = "Agent 标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "My Agent") - @NotBlank(message = "Agent 标题不能为空") - @JsonProperty("title") - private String title; - - @Schema(description = "DSL 定义 (画布 JSON)", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "DSL 定义不能为空") - @JsonProperty("dsl") - private Map dsl; - - @Schema(description = "描述", example = "这是一个测试 Agent") - @JsonProperty("description") - private String description; - - @Schema(description = "头像 URL", example = "http://example.com/avatar.png") - @JsonProperty("avatar") - private String avatar; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Agent 更新请求") - public static class UpdateReq implements Serializable { - @Schema(description = "Agent 标题", example = "Updated Agent") - @JsonProperty("title") - private String title; - - @Schema(description = "DSL 定义 (画布 JSON)") - @JsonProperty("dsl") - private Map dsl; - - @Schema(description = "描述") - @JsonProperty("description") - private String description; - - @Schema(description = "头像 URL") - @JsonProperty("avatar") - private String avatar; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Agent 列表请求") - public static class ListReq implements Serializable { - @Schema(description = "页码", defaultValue = "1") - @JsonProperty("page") - @Builder.Default - private Integer page = 1; - - @Schema(description = "每页大小", defaultValue = "10") - @JsonProperty("page_size") - @Builder.Default - private Integer pageSize = 10; - - @Schema(description = "排序字段", defaultValue = "update_time") - @JsonProperty("orderby") - @Builder.Default - private String orderby = "update_time"; - - @Schema(description = "是否降序", defaultValue = "true") - @JsonProperty("desc") - @Builder.Default - private Boolean desc = true; - - @Schema(description = "Agent ID 过滤") - @JsonProperty("id") - private String id; - - @Schema(description = "标题模糊搜索") - @JsonProperty("title") - private String title; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Agent 响应对象") - public static class AgentVO implements Serializable { - @Schema(description = "Agent ID") - @JsonProperty("id") - private String id; - - @Schema(description = "标题") - @JsonProperty("title") - private String title; - - @Schema(description = "描述") - @JsonProperty("description") - private String description; - - @Schema(description = "头像") - @JsonProperty("avatar") - private String avatar; - - @Schema(description = "DSL 定义") - @JsonProperty("dsl") - private Map dsl; - - @Schema(description = "创建者 ID") - @JsonProperty("user_id") - private String userId; - - @Schema(description = "画布分类") - @JsonProperty("canvas_category") - private String canvasCategory; - - @Schema(description = "创建时间 (时间戳)") - @JsonProperty("create_time") - private Long createTime; - - @Schema(description = "更新时间 (时间戳)") - @JsonProperty("update_time") - private Long updateTime; - } - - // ========== 2. Webhook 调试与追踪 - 对应 RAGFlow_Agent接口详解 ========== - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Webhook 触发请求 (参数动态)") - public static class WebhookTriggerReq implements Serializable { - @Schema(description = "输入变量", requiredMode = Schema.RequiredMode.REQUIRED) - @NotNull(message = "输入变量不能为空") - @JsonProperty("inputs") - private Map inputs; - - @Schema(description = "查询词", example = "Hello") - @JsonProperty("query") - private String query; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Webhook 追踪请求") - public static class WebhookTraceReq implements Serializable { - @Schema(description = "时间戳游标", example = "1700000000.0") - @JsonProperty("since_ts") - private Double sinceTs; - - @Schema(description = "Webhook ID") - @JsonProperty("webhook_id") - private String webhookId; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Webhook 追踪响应") - public static class WebhookTraceVO implements Serializable { - @Schema(description = "Webhook ID") - @JsonProperty("webhook_id") - private String webhookId; - - @Schema(description = "是否结束") - @JsonProperty("finished") - private Boolean finished; - - @Schema(description = "下一次查询的时间戳游标") - @JsonProperty("next_since_ts") - private Double nextSinceTs; - - @Schema(description = "事件列表") - @JsonProperty("events") - private List events; - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "追踪事件项") - public static class TraceEvent implements Serializable { - @Schema(description = "时间戳") - @JsonProperty("ts") - private Double ts; - - @Schema(description = "事件类型") - @JsonProperty("event") - private String event; - - @Schema(description = "事件数据") - @JsonProperty("data") - private Object data; - } - } - - // ========== 3. Agent 会话 (Session) - 对应 RAGFlow_Agent_Dify接口详解 ========== - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Session 创建请求") - public static class SessionCreateReq implements Serializable { - @Schema(description = "用户 ID") - @JsonProperty("user_id") - private String userId; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Session 列表请求") - public static class SessionListReq implements Serializable { - @Schema(description = "页码", defaultValue = "1") - @JsonProperty("page") - @Builder.Default - private Integer page = 1; - - @Schema(description = "每页大小", defaultValue = "10") - @JsonProperty("page_size") - @Builder.Default - private Integer pageSize = 10; - - @Schema(description = "排序字段", defaultValue = "create_time") - @JsonProperty("orderby") - @Builder.Default - private String orderby = "create_time"; - - @Schema(description = "是否降序", defaultValue = "true") - @JsonProperty("desc") - @Builder.Default - private Boolean desc = true; - - @Schema(description = "Session ID") - @JsonProperty("id") - private String id; - - @Schema(description = "用户 ID") - @JsonProperty("user_id") - private String userId; - - @Schema(description = "是否返回 DSL") - @JsonProperty("dsl") - @Builder.Default - private Boolean dsl = false; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Session 批量删除请求") - public static class SessionBatchDeleteReq implements Serializable { - @Schema(description = "会话 ID 列表", requiredMode = Schema.RequiredMode.REQUIRED) - @JsonProperty("ids") - @NotEmpty(message = "ID列表不能为空") - private List ids; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Session 响应对象") - public static class SessionVO implements Serializable { - @Schema(description = "Session ID") - @JsonProperty("id") - private String id; - - @Schema(description = "Agent ID") - @JsonProperty("agent_id") - private String agentId; - - @Schema(description = "用户 ID") - @JsonProperty("user_id") - private String userId; - - @Schema(description = "来源") - @JsonProperty("source") - private String source; - - @Schema(description = "DSL 定义") - @JsonProperty("dsl") - private Map dsl; - - @Schema(description = "消息列表") - @JsonProperty("messages") - private List> messages; - } - - // ========== 4. Agent 对话 (Completion) - 对应 RAGFlow_Agent_Dify接口详解 ========== - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Completion 对话请求") - public static class CompletionReq implements Serializable { - @Schema(description = "会话 ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "会话 ID 不能为空") - @JsonProperty("session_id") - private String sessionId; - - @Schema(description = "用户问题") - @JsonProperty("question") - private String question; - - @Schema(description = "是否流式返回", defaultValue = "true") - @JsonProperty("stream") - @Builder.Default - private Boolean stream = true; - - @Schema(description = "是否返回追踪信息", defaultValue = "false") - @JsonProperty("return_trace") - @Builder.Default - private Boolean returnTrace = false; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Completion 对话响应") - public static class CompletionVO implements Serializable { - @Schema(description = "会话 ID") - @JsonProperty("id") - private String id; - - @Schema(description = "回复内容") - @JsonProperty("content") - private String content; - - @Schema(description = "引用来源") - @JsonProperty("reference") - private Map reference; - - @Schema(description = "追踪信息") - @JsonProperty("trace") - private List trace; - } - - // ========== 5. Dify 兼容检索 - 对应 RAGFlow_Agent_Dify接口详解 ========== - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Dify 兼容检索请求") - public static class DifyRetrievalReq implements Serializable { - @Schema(description = "知识库 ID") - @JsonProperty("knowledge_id") - private String knowledgeId; - - @Schema(description = "查询词") - @JsonProperty("query") - private String query; - - @Schema(description = "检索设置") - @JsonProperty("retrieval_setting") - private Map retrievalSetting; - - @Schema(description = "元数据过滤条件") - @JsonProperty("metadata_condition") - private Map metadataCondition; - - @Schema(description = "是否使用知识图谱") - @JsonProperty("use_kg") - private Boolean useKg; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "Dify 兼容检索响应") - public static class DifyRetrievalVO implements Serializable { - @Schema(description = "检索结果列表") - @JsonProperty("records") - private List records; - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "检索记录") - public static class Record implements Serializable { - @Schema(description = "内容") - @JsonProperty("content") - private String content; - - @Schema(description = "相似度分数") - @JsonProperty("score") - private Double score; - - @Schema(description = "标题") - @JsonProperty("title") - private String title; - - @Schema(description = "元数据") - @JsonProperty("metadata") - private Map metadata; - } - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/bot/BotDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/bot/BotDTO.java deleted file mode 100644 index 53d4ac43..00000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/bot/BotDTO.java +++ /dev/null @@ -1,126 +0,0 @@ -package xiaozhi.modules.knowledge.dto.bot; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.*; - -@Schema(description = "外部机器人 (Bot) 聚合 DTO") -public class BotDTO { - - // ========== 1. SearchBot (检索机器人) ========== - - // 对应 /api/v1/searchbots/ask - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "SearchBot 提问请求") - public static class SearchAskReq implements Serializable { - @Schema(description = "用户问题", requiredMode = Schema.RequiredMode.REQUIRED, example = "What is RAG?") - @NotBlank(message = "问题不能为空") - @JsonProperty("question") - private String question; - - @Schema(description = "是否返回引用", defaultValue = "false") - @JsonProperty("quote") - @Builder.Default - private Boolean quote = false; - - @Schema(description = "是否流式返回", defaultValue = "true") - @JsonProperty("stream") - @Builder.Default - private Boolean stream = true; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "SearchBot 提问响应") - public static class SearchAskVO implements Serializable { - @Schema(description = "回答内容") - @JsonProperty("answer") - private String answer; - - @Schema(description = "引用来源 (Value 结构通常对应 RetrievalDTO.HitVO)") - @JsonProperty("reference") - private Map reference; - } - - // 对应 /api/v1/searchbots/related_questions - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "相关问题请求") - public static class RelatedQuestionReq implements Serializable { - @Schema(description = "用户问题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "问题不能为空") - @JsonProperty("question") - private String question; - } - - // 对应 /api/v1/searchbots/mindmap - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "思维导图请求") - public static class MindMapReq implements Serializable { - @Schema(description = "用户问题", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "问题不能为空") - @JsonProperty("question") - private String question; - } - - // ========== 2. AgentBot (嵌入式 Agent) ========== - - // 对应 /api/v1/agentbots/{id}/inputs - @Data - @Builder - @AllArgsConstructor - @Schema(description = "AgentBot 输入参数请求") - public static class AgentInputsReq implements Serializable { - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "AgentBot 输入参数定义响应") - public static class AgentInputsVO implements Serializable { - @Schema(description = "表单变量定义列表") - @JsonProperty("variables") - private List> variables; - } - - // 对应 /api/v1/agentbots/{id}/completions - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "AgentBot 对话请求") - public static class AgentCompletionReq implements Serializable { - @Schema(description = "输入参数值") - @JsonProperty("inputs") - private Map inputs; - - @Schema(description = "用户查询", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "查询内容不能为空") - @JsonProperty("question") - private String question; - - @Schema(description = "是否流式返回", defaultValue = "true") - @JsonProperty("stream") - @Builder.Default - private Boolean stream = true; - - @Schema(description = "会话 ID") - @JsonProperty("session_id") - private String sessionId; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/chat/ChatCompletionRequest.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/chat/ChatCompletionRequest.java deleted file mode 100644 index 681b13d3..00000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/chat/ChatCompletionRequest.java +++ /dev/null @@ -1,50 +0,0 @@ -package xiaozhi.modules.knowledge.dto.chat; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -/** - * 聊天对话请求 DTO (OpenAI 兼容格式) - */ -@Data -@Schema(description = "聊天对话请求") -public class ChatCompletionRequest implements Serializable { - - @Schema(description = "模型标识 (对应 agent_id 或 bot_id)", requiredMode = Schema.RequiredMode.REQUIRED) - @JsonProperty("model") - private String model; - - @Schema(description = "对话消息列表", requiredMode = Schema.RequiredMode.REQUIRED) - @JsonProperty("messages") - private List messages; - - @Schema(description = "是否流式返回", defaultValue = "false") - @JsonProperty("stream") - private Boolean stream = false; - - @Schema(description = "温度系数 (0-1)", defaultValue = "0.7") - @JsonProperty("temperature") - private Double temperature; - - @Schema(description = "Session ID (可选,用于延续会话)") - @JsonProperty("session_id") - private String sessionId; - - @Schema(description = "其他RAGFlow特定参数 (可选)") - private Map extra; - - @Data - public static class Message implements Serializable { - @Schema(description = "角色 (system, user, assistant)", requiredMode = Schema.RequiredMode.REQUIRED) - private String role; - - @Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED) - private String content; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/chat/ChatDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/chat/ChatDTO.java deleted file mode 100644 index d7ca8d60..00000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/chat/ChatDTO.java +++ /dev/null @@ -1,523 +0,0 @@ -package xiaozhi.modules.knowledge.dto.chat; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.*; - -/** - * 对话管理聚合 DTO - *

- * 容器类,内含对话助手、会话和消息的所有请求/响应对象。 - *

- */ -@Schema(description = "对话管理聚合 DTO") -public class ChatDTO { - - // ========== 1. 对话助手 (Assistant/Bot) 相关 ========== - - /** - * 提示词配置 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "提示词配置") - public static class PromptConfig implements Serializable { - - @Schema(description = "系统提示词", example = "你是一个专业的客服助手...") - @JsonProperty("prompt") - private String systemPrompt; - - @Schema(description = "开场白", example = "您好,我是您的智能助手,请问有什么可以帮您?") - private String opener; - - @Schema(description = "空结果回复", example = "抱歉,我没有找到相关信息。") - @JsonProperty("empty_response") - private String emptyResponse; - - @Schema(description = "是否展示引用", example = "true") - @JsonProperty("show_quote") - private Boolean quote; - - @Schema(description = "是否启用 TTS", example = "false") - private Boolean tts; - - @Schema(description = "相似度阈值 (0.0 - 1.0)", example = "0.2") - @JsonProperty("similarity_threshold") - private Float similarityThreshold; - - @Schema(description = "关键词相似度权重 (0.0 - 1.0)", example = "0.7") - @JsonProperty("keywords_similarity_weight") - private Float vectorSimilarityWeight; - - @Schema(description = "检索 Top N", example = "6") - @JsonProperty("top_n") - private Integer topK; - - @Schema(description = "Rerank 模型", example = "rerank_model_001") - @JsonProperty("rerank_model") - private String rerankId; - - @Schema(description = "是否启用多轮对话优化", example = "false") - @JsonProperty("refine_multiturn") - private Boolean refineMultigraph; - - @Schema(description = "变量列表") - private List> variables; - } - - /** - * LLM 配置 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "LLM 模型配置") - public static class LLMConfig implements Serializable { - - @NotBlank(message = "模型名称不能为空") - @Schema(description = "模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "gpt-4") - @JsonProperty("model_name") - private String modelName; - - @Schema(description = "温度参数 (0.0 - 2.0)", example = "0.7") - private Float temperature; - - @Schema(description = "Top P 采样", example = "0.9") - @JsonProperty("top_p") - private Float topP; - - @Schema(description = "最大 Token 数", example = "4096") - @JsonProperty("max_tokens") - private Integer maxTokens; - - @Schema(description = "存在惩罚", example = "0.0") - @JsonProperty("presence_penalty") - private Float presencePenalty; - - @Schema(description = "频率惩罚", example = "0.0") - @JsonProperty("frequency_penalty") - private Float frequencyPenalty; - } - - /** - * 创建助手请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "创建助手请求") - public static class AssistantCreateReq implements Serializable { - - @NotBlank(message = "助手名称不能为空") - @Schema(description = "助手名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "智能客服助手") - private String name; - - @Schema(description = "助手头像 (Base64 编码)", example = "") - private String avatar; - - @Schema(description = "关联的知识库 ID 列表", example = "[\"kb_001\", \"kb_002\"]") - @JsonProperty("dataset_ids") - private List datasetIds; - - @Schema(description = "助手描述", example = "这是一个智能客服助手") - private String description; - - @Schema(description = "LLM 模型配置") - @JsonProperty("llm") - private LLMConfig llm; - - @Schema(description = "提示词配置") - @JsonProperty("prompt") - private PromptConfig promptConfig; - } - - /** - * 更新助手请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "更新助手请求") - public static class AssistantUpdateReq implements Serializable { - - @Schema(description = "助手名称", example = "智能客服助手 V2") - private String name; - - @Schema(description = "助手头像 (Base64 编码)", example = "") - private String avatar; - - @Schema(description = "关联的知识库 ID 列表", example = "[\"kb_001\", \"kb_002\"]") - @JsonProperty("dataset_ids") - private List datasetIds; - - @Schema(description = "助手描述", example = "这是一个智能客服助手") - private String description; - - @Schema(description = "LLM 模型配置") - @JsonProperty("llm") - private LLMConfig llm; - - @Schema(description = "提示词配置") - @JsonProperty("prompt") - private PromptConfig promptConfig; - } - - /** - * 查询助手列表请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "查询助手列表请求") - public static class AssistantListReq implements Serializable { - - @Schema(description = "页码 (从 1 开始)", example = "1") - private Integer page; - - @Schema(description = "每页数量", example = "30") - @JsonProperty("page_size") - private Integer pageSize; - - @Schema(description = "按名称过滤 (模糊匹配)", example = "客服") - private String name; - - @Schema(description = "排序字段: create_time / update_time", example = "create_time") - private String orderby; - - @Schema(description = "是否降序", example = "true") - private Boolean desc; - - @Schema(description = "按 ID 精确筛选", example = "assistant_001") - private String id; - } - - /** - * 助手详情 VO - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "助手详情 VO") - public static class AssistantVO implements Serializable { - - @Schema(description = "助手 ID", example = "assistant_001") - private String id; - - @Schema(description = "租户 ID", example = "tenant_001") - @JsonProperty("tenant_id") - private String tenantId; - - @Schema(description = "助手名称", example = "智能客服助手") - private String name; - - @Schema(description = "助手头像", example = "") - private String avatar; - - @Schema(description = "关联的知识库 ID 列表") - @JsonProperty("dataset_ids") - private List datasetIds; - - @Schema(description = "关联的知识库列表 (详情)") - private List datasets; - - @Schema(description = "助手描述") - private String description; - - @Schema(description = "LLM 模型配置") - @JsonProperty("llm") - private LLMConfig llm; - - @Schema(description = "提示词配置") - @JsonProperty("prompt") - private PromptConfig promptConfig; - - @Schema(description = "创建时间 (时间戳)", example = "1700000000000") - @JsonProperty("create_time") - private Long createTime; - - @Schema(description = "更新时间 (时间戳)", example = "1700000001000") - @JsonProperty("update_time") - private Long updateTime; - } - - /** - * 删除助手请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "删除助手请求") - public static class AssistantDeleteReq implements Serializable { - - @Schema(description = "要删除的助手 ID 列表", example = "[\"assistant_001\", \"assistant_002\"]") - private List ids; - } - - // ========== 2. 会话 (Session) 相关 ========== - - /** - * 创建会话请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "创建会话请求") - public static class SessionCreateReq implements Serializable { - - @Schema(description = "会话名称", example = "技术咨询会话") - private String name; - - @Schema(description = "用户 ID", example = "user_001") - @JsonProperty("user_id") - private String userId; - } - - /** - * 更新会话请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "更新会话请求") - public static class SessionUpdateReq implements Serializable { - - @Schema(description = "会话名称", example = "技术咨询会话 - 更新") - private String name; - } - - /** - * 查询会话列表请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "查询会话列表请求") - public static class SessionListReq implements Serializable { - - @Schema(description = "助手 ID", example = "assistant_001") - @JsonProperty("assistant_id") - private String assistantId; - - @Schema(description = "页码 (从 1 开始)", example = "1") - private Integer page; - - @Schema(description = "每页数量", example = "30") - @JsonProperty("page_size") - private Integer pageSize; - - @Schema(description = "按名称过滤", example = "技术") - private String name; - - @Schema(description = "排序字段", example = "create_time") - private String orderby; - - @Schema(description = "是否降序", example = "true") - private Boolean desc; - - @Schema(description = "会话 ID 精确筛选", example = "session_001") - private String id; - - @Schema(description = "用户标识筛选", example = "user_001") - @JsonProperty("user_id") - private String userId; - } - - /** - * 会话详情 VO - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "会话详情 VO") - public static class SessionVO implements Serializable { - - @Schema(description = "会话 ID", example = "session_001") - private String id; - - @Schema(description = "助手 ID", example = "assistant_001") - @JsonProperty("chat_id") - private String chatId; - - @Schema(description = "助手 ID (兼容旧版)", example = "assistant_001") - @JsonProperty("assistant_id") - private String assistantId; - - @Schema(description = "会话名称", example = "技术咨询会话") - private String name; - - @Schema(description = "创建时间 (时间戳)", example = "1700000000000") - @JsonProperty("create_time") - private Long createTime; - - @Schema(description = "更新时间 (时间戳)", example = "1700000001000") - @JsonProperty("update_time") - private Long updateTime; - - @Schema(description = "创建日期", example = "2024-05-01 10:00:00") - @JsonProperty("create_date") - private String createDate; - - @Schema(description = "更新日期", example = "2024-05-01 10:00:00") - @JsonProperty("update_date") - private String updateDate; - - @Schema(description = "用户 ID", example = "user_001") - @JsonProperty("user_id") - private String userId; - - @Schema(description = "对话历史消息列表") - private List> messages; - } - - /** - * 删除会话请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "删除会话请求") - public static class SessionDeleteReq implements Serializable { - - @Schema(description = "要删除的会话 ID 列表", example = "[\"session_001\", \"session_002\"]") - private List ids; - } - - // ========== 3. 消息/对话 (Completion) 相关 ========== - - /** - * 发送消息请求 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "发送消息请求") - public static class CompletionReq implements Serializable { - - @NotBlank(message = "问题内容不能为空") - @Schema(description = "用户问题", requiredMode = Schema.RequiredMode.REQUIRED, example = "请介绍一下你们的产品") - private String question; - - @Schema(description = "是否使用流式响应 (SSE)", example = "true") - @Builder.Default - private Boolean stream = true; - - @NotBlank(message = "会话 ID 不能为空") - @Schema(description = "会话 ID (可选,不传则创建新会话)", example = "session_001") - @JsonProperty("session_id") - private String sessionId; - - @Schema(description = "是否展示引用", example = "true") - private Boolean quote; - - @Schema(description = "指定检索的文档 ID 列表 (逗号分隔)", example = "doc_001,doc_002") - @JsonProperty("doc_ids") - private String docIds; - - @Schema(description = "元数据过滤条件") - @JsonProperty("metadata_condition") - private Map metadataCondition; - } - - /** - * 消息响应 VO - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "消息响应 VO") - public static class CompletionVO implements Serializable { - - @Schema(description = "AI 回答内容") - private String answer; - - @Schema(description = "引用信息") - private Reference reference; - - @Schema(description = "会话 ID", example = "session_001") - @JsonProperty("session_id") - private String sessionId; - - @Schema(description = "任务 ID (用于流式响应追踪)", example = "task_001") - @JsonProperty("task_id") - private String taskId; - - /** - * 引用信息 (检索命中结果) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "引用信息") - public static class Reference implements Serializable { - - @Schema(description = "命中的文档块列表") - private List chunks; - - @Schema(description = "文档聚合信息") - @JsonProperty("doc_aggs") - private List docAggs; - } - - /** - * 文档聚合信息 - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "文档聚合信息") - public static class DocAgg implements Serializable { - - @Schema(description = "文档 ID", example = "doc_001") - @JsonProperty("doc_id") - private String docId; - - @Schema(description = "文档名称", example = "产品手册.pdf") - @JsonProperty("doc_name") - private String docName; - - @Schema(description = "命中次数", example = "3") - private Integer count; - } - } - - /** - * 简易知识库 VO (用于 Assistant 列表) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "简易知识库 VO") - public static class SimpleDatasetVO implements Serializable { - @Schema(description = "知识库 ID") - private String id; - @Schema(description = "知识库名称") - private String name; - @Schema(description = "头像") - private String avatar; - @Schema(description = "分块数量") - @JsonProperty("chunk_num") - private Integer chunkNum; - } -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/common/CommonDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/common/CommonDTO.java deleted file mode 100644 index ec3b597e..00000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/common/CommonDTO.java +++ /dev/null @@ -1,79 +0,0 @@ -package xiaozhi.modules.knowledge.dto.common; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import java.io.Serializable; -import java.util.List; -import java.util.Map; -import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.*; - -@Schema(description = "通用扩展功能 DTO") -public class CommonDTO { - - // ========== 1. 引用详情 (detail_share_embedded) ========== - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "引用详情请求") - public static class ReferenceDetailReq implements Serializable { - @Schema(description = "切片 ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "切片 ID 不能为空") - @JsonProperty("chunk_id") - private String chunkId; - - @Schema(description = "知识库 ID") - @JsonProperty("knowledge_id") - private String knowledgeId; - } - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "引用详情响应") - public static class ReferenceDetailVO implements Serializable { - @Schema(description = "切片 ID") - @JsonProperty("chunk_id") - private String chunkId; - - @Schema(description = "完整内容") - @JsonProperty("content_with_weight") - private String contentWithWeight; - - @Schema(description = "文档名称") - @JsonProperty("doc_name") - private String docName; - - @Schema(description = "图片 ID 列表") - @JsonProperty("img_id") - private String imageId; // 注意:RAGFlow 有时返回 String 有时返回 List,需根据实际情况确认,暂定 String 用于 ID - - @Schema(description = "文档 ID") - @JsonProperty("doc_id") - private String docId; - } - - // ========== 2. 通用问答 (ask_about) - 调试用 ========== - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @Schema(description = "通用问答请求 (调试用)") - public static class AskAboutReq implements Serializable { - @Schema(description = "用户问题", requiredMode = Schema.RequiredMode.REQUIRED, example = "What is this dataset about?") - @NotBlank(message = "问题不能为空") - @JsonProperty("question") - private String question; - - @Schema(description = "数据集 ID 列表", requiredMode = Schema.RequiredMode.REQUIRED) - @NotEmpty(message = "数据集列表不能为空") - @JsonProperty("dataset_ids") - private List datasetIds; - } - - // 响应通常复用 String 或者简单的 Map 结构,视具体实现而定,暂不定义专用 VO -} diff --git a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/file/FileDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/file/FileDTO.java deleted file mode 100644 index 816ed8ee..00000000 --- a/main/manager-api/src/main/java/xiaozhi/modules/knowledge/dto/file/FileDTO.java +++ /dev/null @@ -1,363 +0,0 @@ -package xiaozhi.modules.knowledge.dto.file; - -import lombok.*; -import io.swagger.v3.oas.annotations.media.Schema; -import java.io.Serializable; -import java.util.List; -import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.*; -import org.springframework.web.multipart.MultipartFile; - -/** - * 文件管理聚合 DTO - *

- * 容器类,内含文件模块所有请求/响应对象的静态内部类定义。 - *

- */ -@Schema(description = "文件管理聚合 DTO") -public class FileDTO { - - // ========== 请求类 ========== - - /** - * 文件上传请求 (对应接口 1: upload) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "文件上传请求") - public static class UploadReq implements Serializable { - - @NotNull(message = "文件不能为空") - @Schema(description = "上传的文件", requiredMode = Schema.RequiredMode.REQUIRED) - private MultipartFile file; - - @Schema(description = "父文件夹 ID (为空则上传到根目录)", example = "folder_001") - @JsonProperty("parent_id") - private String parentId; - } - - /** - * 新建文件夹请求 (对应接口 2: create) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "新建文件夹请求") - public static class CreateReq implements Serializable { - - @NotBlank(message = "文件夹名称不能为空") - @Schema(description = "文件夹名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "新建文件夹") - private String name; - - @Schema(description = "父文件夹 ID (为空则创建在根目录)", example = "folder_001") - @JsonProperty("parent_id") - private String parentId; - - @NotBlank(message = "类型不能为空") - @Schema(description = "类型: FOLDER", requiredMode = Schema.RequiredMode.REQUIRED, example = "FOLDER") - @Builder.Default - private String type = "FOLDER"; - } - - /** - * 重命名请求 (对应接口 6: rename) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "重命名请求") - public static class RenameReq implements Serializable { - - @NotBlank(message = "文件 ID 不能为空") - @Schema(description = "文件/文件夹 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "file_001") - @JsonProperty("file_id") - private String fileId; - - @NotBlank(message = "新名称不能为空") - @Schema(description = "新名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "重命名后的文件") - private String name; - } - - /** - * 移动请求 (对应接口 7: move) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "移动请求") - public static class MoveReq implements Serializable { - - @NotEmpty(message = "源文件 ID 列表不能为空") - @Schema(description = "源文件/文件夹 ID 列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[\"file_001\", \"file_002\"]") - @JsonProperty("src_file_ids") - private List srcFileIds; - - @NotBlank(message = "目标文件夹 ID 不能为空") - @Schema(description = "目标文件夹 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "folder_002") - @JsonProperty("dest_file_id") - private String destFileId; - } - - /** - * 批量删除请求 (对应接口 8: rm) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "批量删除请求") - public static class RemoveReq implements Serializable { - - @NotEmpty(message = "文件 ID 列表不能为空") - @Schema(description = "文件/文件夹 ID 列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[\"file_001\", \"file_002\"]") - @JsonProperty("file_ids") - private List fileIds; - } - - /** - * 导入知识库请求 (对应接口 9: convert) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "导入知识库请求") - public static class ConvertReq implements Serializable { - - @NotEmpty(message = "文件 ID 列表不能为空") - @Schema(description = "文件 ID 列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[\"file_001\", \"file_002\"]") - @JsonProperty("file_ids") - private List fileIds; - - @NotEmpty(message = "知识库 ID 列表不能为空") - @Schema(description = "目标知识库 ID 列表", requiredMode = Schema.RequiredMode.REQUIRED, example = "[\"kb_001\"]") - @JsonProperty("kb_ids") - private List kbIds; - } - - /** - * 列表查询请求 (对应接口 3: list_files) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "列表查询请求") - public static class ListReq implements Serializable { - - @Schema(description = "父文件夹 ID (为空则查询根目录)", example = "folder_001") - @JsonProperty("parent_id") - private String parentId; - - @Schema(description = "关键词搜索", example = "文档") - private String keywords; - - @Schema(description = "页码 (从 1 开始)", example = "1") - private Integer page; - - @Schema(description = "每页数量", example = "30") - @JsonProperty("page_size") - private Integer pageSize; - - @Schema(description = "排序字段: create_time / update_time / name / size", example = "create_time") - private String orderby; - - @Schema(description = "是否降序", example = "true") - private Boolean desc; - } - - // ========== 响应类 ========== - - /** - * 文件/文件夹基础信息 VO - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "文件/文件夹基础信息") - public static class InfoVO implements Serializable { - - @Schema(description = "文件/文件夹 ID", example = "file_001") - private String id; - - @Schema(description = "父文件夹 ID", example = "folder_001") - @JsonProperty("parent_id") - private String parentId; - - @Schema(description = "租户 ID", example = "tenant_001") - @JsonProperty("tenant_id") - private String tenantId; - - @Schema(description = "创建者 ID", example = "user_001") - @JsonProperty("created_by") - private String createdBy; - - @Schema(description = "类型: FOLDER / FILE", example = "FOLDER") - private String type; - - @Schema(description = "名称", example = "我的文件夹") - private String name; - - @Schema(description = "路径位置", example = "/root/folder") - private String location; - - @Schema(description = "文件大小 (字节)", example = "1024") - private Long size; - - @Schema(description = "来源类型", example = "local") - @JsonProperty("source_type") - private String sourceType; - - @Schema(description = "创建时间 (时间戳)", example = "1700000000000") - @JsonProperty("create_time") - private Long createTime; - - @Schema(description = "创建日期 (格式化)", example = "2024-01-15 10:30:00") - @JsonProperty("create_date") - private String createDate; - - @Schema(description = "更新时间 (时间戳)", example = "1700000001000") - @JsonProperty("update_time") - private Long updateTime; - - @Schema(description = "更新日期 (格式化)", example = "2024-01-15 11:00:00") - @JsonProperty("update_date") - private String updateDate; - - @Schema(description = "文件扩展名", example = "pdf") - private String extension; - } - - /** - * 列表响应 VO (对应接口 3: list_files) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "文件列表响应") - public static class ListVO implements Serializable { - - @Schema(description = "总记录数", example = "100") - private Long total; - - @Schema(description = "当前父文件夹信息") - @JsonProperty("parent_folder") - private InfoVO parentFolder; - - @Schema(description = "文件/文件夹列表") - private List files; - - @Schema(description = "面包屑导航路径") - private List breadcrumb; - } - - /** - * 转换结果项 VO (对应接口 9: convert) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "文件转换结果项") - public static class ConvertVO implements Serializable { - - @Schema(description = "转换记录 ID", example = "convert_001") - private String id; - - @Schema(description = "源文件 ID", example = "file_001") - @JsonProperty("file_id") - private String fileId; - - @Schema(description = "目标文档 ID", example = "doc_001") - @JsonProperty("document_id") - private String documentId; - - @Schema(description = "创建时间 (时间戳)", example = "1700000000000") - @JsonProperty("create_time") - private Long createTime; - - @Schema(description = "创建日期 (格式化)", example = "2024-01-15 10:30:00") - @JsonProperty("create_date") - private String createDate; - - @Schema(description = "更新时间 (时间戳)", example = "1700000001000") - @JsonProperty("update_time") - private Long updateTime; - - @Schema(description = "更新日期 (格式化)", example = "2024-01-15 11:00:00") - @JsonProperty("update_date") - private String updateDate; - } - - /** - * 转换状态 VO (对应接口 10: get_convert_status) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "文件转换状态") - public static class ConvertStatusVO implements Serializable { - - @Schema(description = "转换状态: pending / processing / completed / failed", example = "completed") - private String status; - - @Schema(description = "转换进度 (0.0 - 1.0)", example = "1.0") - private Float progress; - - @Schema(description = "状态消息", example = "转换完成") - private String message; - } - - /** - * 面包屑 VO (对应接口 12: all_parent_folder) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "面包屑导航 (所有父文件夹)") - public static class BreadcrumbVO implements Serializable { - - @Schema(description = "父文件夹列表 (从根到当前的路径)") - @JsonProperty("parent_folders") - private List parentFolders; - } - - /** - * 根目录信息 VO (对应接口 10: get_root_folder) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "根目录信息") - public static class RootFolderVO implements Serializable { - - @Schema(description = "根文件夹信息") - @JsonProperty("root_folder") - private InfoVO rootFolder; - } - - /** - * 父目录信息 VO (对应接口 11: get_parent_folder) - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Schema(description = "父目录信息") - public static class ParentFolderVO implements Serializable { - - @Schema(description = "父文件夹信息") - @JsonProperty("parent_folder") - private InfoVO parentFolder; - } -}