feat(rag): 扩展分块模式支持更多文档处理策略
- 将分块模式取值范围从 0-2 扩展到 0-5,新增 Separator、ByPage 和 Token 模式 - 更新知识库创建和更新请求验证器以支持新的分块模式范围 - 修改文档上传端点的分块策略覆盖逻辑以兼容新模式 - 更新相关错误消息提示以反映完整的分块模式选项 - 在菜单端点中添加渲染类型和运行时视图模式字段支持 - 修改菜单更新请求参数 ID 类型从 Guid 调整为 long 类型
This commit is contained in:
parent
2181f7dd49
commit
d6dc6be51d
@ -1,5 +1,6 @@
|
||||
using BuildFlow.Platform.Application.Menus.Commands;
|
||||
using BuildFlow.Platform.Application.Menus.DTOs;
|
||||
using BuildFlow.Platform.Domain.Enums;
|
||||
using MediatR;
|
||||
|
||||
namespace BuildFlow.Host.Endpoints.Platform.Menus;
|
||||
@ -24,6 +25,9 @@ public class CreateMenuEndpoint(IMediator mediator) : Endpoint<CreateMenuRequest
|
||||
Path = req.Path,
|
||||
Component = req.Component,
|
||||
Redirect = req.Redirect,
|
||||
RenderType = MenuRuntimeFieldParser.ParseRenderType(req.RenderType) ?? MenuRenderType.Route,
|
||||
FormDefinitionId = req.FormDefinitionId,
|
||||
RuntimeViewMode = MenuRuntimeFieldParser.ParseRuntimeViewMode(req.RuntimeViewMode) ?? MenuRuntimeViewMode.List,
|
||||
Title = req.Title,
|
||||
Code = req.Code,
|
||||
Icon = req.Icon,
|
||||
|
||||
@ -25,6 +25,9 @@ public class UpdateMenuEndpoint(IMediator mediator) : Endpoint<UpdateMenuEndpoin
|
||||
Path = req.Path,
|
||||
Component = req.Component,
|
||||
Redirect = req.Redirect,
|
||||
RenderType = MenuRuntimeFieldParser.ParseRenderType(req.RenderType),
|
||||
FormDefinitionId = req.FormDefinitionId,
|
||||
RuntimeViewMode = MenuRuntimeFieldParser.ParseRuntimeViewMode(req.RuntimeViewMode),
|
||||
Title = req.Title,
|
||||
Code = req.Code,
|
||||
Icon = req.Icon,
|
||||
|
||||
@ -4,12 +4,15 @@ namespace BuildFlow.Host.Endpoints.Platform.Menus;
|
||||
/// 更新菜单请求体。携带路由 Id。
|
||||
/// </summary>
|
||||
public record UpdateMenuEndpointRequest(
|
||||
Guid Id,
|
||||
Guid? ParentId,
|
||||
long Id,
|
||||
long? ParentId,
|
||||
string? Name,
|
||||
string? Path,
|
||||
string? Component,
|
||||
string? Redirect,
|
||||
string? RenderType,
|
||||
Guid? FormDefinitionId,
|
||||
string? RuntimeViewMode,
|
||||
string? Title,
|
||||
string? Code,
|
||||
string? Icon,
|
||||
|
||||
@ -26,10 +26,10 @@ public class UploadDocumentEndpoint(IMediator mediator) : Endpoint<UploadDocumen
|
||||
if (file is null)
|
||||
throw new DomainExceptions.BusinessException("请上传文件");
|
||||
|
||||
// 分块策略覆盖:0=General,1=Heading,2=ParentChild;null=用知识库默认
|
||||
// 分块策略覆盖:null=用知识库默认;0-5 与知识库策略枚举保持一致。
|
||||
ChunkingMode? overrideMode = req.ChunkingMode switch
|
||||
{
|
||||
>= 0 and <= 2 => (ChunkingMode)req.ChunkingMode.Value,
|
||||
>= 0 and <= 5 => (ChunkingMode)req.ChunkingMode.Value,
|
||||
_ => null
|
||||
};
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ public class UploadDocumentRequestValidator : Validator<UploadDocumentRequest>
|
||||
});
|
||||
|
||||
RuleFor(x => x.ChunkingMode)
|
||||
.InclusiveBetween(0, 2).When(x => x.ChunkingMode.HasValue)
|
||||
.WithMessage("分块模式 ChunkingMode 取值 0=General,1=Heading,2=ParentChild");
|
||||
.InclusiveBetween(0, 5).When(x => x.ChunkingMode.HasValue)
|
||||
.WithMessage("分块模式 ChunkingMode 取值 0=General,1=Heading,2=ParentChild,3=Separator,4=ByPage,5=Token");
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,8 +28,8 @@ public class CreateKnowledgeBaseRequestValidator : Validator<CreateKnowledgeBase
|
||||
.WithMessage("分块重叠 ChunkOverlap 取值范围 0-1000");
|
||||
|
||||
RuleFor(x => x.ChunkingMode)
|
||||
.InclusiveBetween(0, 2).When(x => x.ChunkingMode.HasValue)
|
||||
.WithMessage("分块模式 ChunkingMode 取值 0=General,1=Heading,2=ParentChild");
|
||||
.InclusiveBetween(0, 5).When(x => x.ChunkingMode.HasValue)
|
||||
.WithMessage("分块模式 ChunkingMode 取值 0=General,1=Heading,2=ParentChild,3=Separator,4=ByPage,5=Token");
|
||||
|
||||
RuleFor(x => x.RetrievalMode)
|
||||
.InclusiveBetween(0, 2).When(x => x.RetrievalMode.HasValue)
|
||||
|
||||
@ -31,8 +31,8 @@ public class UpdateKnowledgeBaseRequestValidator : Validator<UpdateKnowledgeBase
|
||||
.WithMessage("分块重叠 ChunkOverlap 取值范围 0-1000");
|
||||
|
||||
RuleFor(x => x.ChunkingMode)
|
||||
.InclusiveBetween(0, 2).When(x => x.ChunkingMode.HasValue)
|
||||
.WithMessage("分块模式 ChunkingMode 取值 0=General,1=Heading,2=ParentChild");
|
||||
.InclusiveBetween(0, 5).When(x => x.ChunkingMode.HasValue)
|
||||
.WithMessage("分块模式 ChunkingMode 取值 0=General,1=Heading,2=ParentChild,3=Separator,4=ByPage,5=Token");
|
||||
|
||||
RuleFor(x => x.RetrievalMode)
|
||||
.InclusiveBetween(0, 2).When(x => x.RetrievalMode.HasValue)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user