-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-jdk17' of https://gitee.com/zhijiantianya/yudao-…
…cloud # Conflicts: # yudao-module-ai/yudao-module-ai-biz/src/main/java/cn/iocoder/yudao/module/ai/service/knowledge/DocServiceImpl.java
- Loading branch information
Showing
45 changed files
with
1,355 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...c/main/java/cn/iocoder/yudao/module/ai/enums/knowledge/AiKnowledgeDocumentStatusEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cn.iocoder.yudao.module.ai.enums.knowledge; | ||
|
||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* AI 知识库-文档状态的枚举 | ||
* | ||
* @author xiaoxin | ||
*/ | ||
@AllArgsConstructor | ||
@Getter | ||
public enum AiKnowledgeDocumentStatusEnum implements IntArrayValuable { | ||
|
||
IN_PROGRESS(10, "索引中"), | ||
SUCCESS(20, "可用"), | ||
FAIL(30, "失败"); | ||
|
||
/** | ||
* 状态 | ||
*/ | ||
private final Integer status; | ||
|
||
/** | ||
* 状态名 | ||
*/ | ||
private final String name; | ||
|
||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(AiKnowledgeDocumentStatusEnum::getStatus).toArray(); | ||
|
||
@Override | ||
public int[] array() { | ||
return ARRAYS; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...ain/java/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cn.iocoder.yudao.module.ai.controller.admin.knowledge; | ||
|
||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeCreateMyReqVO; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeRespVO; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeUpdateMyReqVO; | ||
import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDO; | ||
import cn.iocoder.yudao.module.ai.service.knowledge.AiKnowledgeService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.annotation.Resource; | ||
import jakarta.validation.Valid; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | ||
|
||
@Tag(name = "管理后台 - AI 知识库") | ||
@RestController | ||
@RequestMapping("/ai/knowledge") | ||
@Validated | ||
public class AiKnowledgeController { | ||
|
||
@Resource | ||
private AiKnowledgeService knowledgeService; | ||
|
||
@GetMapping("/my-page") | ||
@Operation(summary = "获取【我的】知识库分页") | ||
public CommonResult<PageResult<AiKnowledgeRespVO>> getKnowledgePageMy(@Validated PageParam pageReqVO) { | ||
PageResult<AiKnowledgeDO> pageResult = knowledgeService.getKnowledgePageMy(getLoginUserId(), pageReqVO); | ||
return success(BeanUtils.toBean(pageResult, AiKnowledgeRespVO.class)); | ||
} | ||
|
||
@PostMapping("/create-my") | ||
@Operation(summary = "创建【我的】知识库") | ||
public CommonResult<Long> createKnowledgeMy(@RequestBody @Valid AiKnowledgeCreateMyReqVO createReqVO) { | ||
return success(knowledgeService.createKnowledgeMy(createReqVO, getLoginUserId())); | ||
} | ||
|
||
@PutMapping("/update-my") | ||
@Operation(summary = "更新【我的】知识库") | ||
public CommonResult<Boolean> updateKnowledgeMy(@RequestBody @Valid AiKnowledgeUpdateMyReqVO updateReqVO) { | ||
knowledgeService.updateKnowledgeMy(updateReqVO, getLoginUserId()); | ||
return success(true); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
.../cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeDocumentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cn.iocoder.yudao.module.ai.controller.admin.knowledge; | ||
|
||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentPageReqVO; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentRespVO; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document.AiKnowledgeDocumentUpdateReqVO; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge.AiKnowledgeDocumentCreateReqVO; | ||
import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeDocumentDO; | ||
import cn.iocoder.yudao.module.ai.service.knowledge.AiKnowledgeDocumentService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.annotation.Resource; | ||
import jakarta.validation.Valid; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
|
||
@Tag(name = "管理后台 - AI 知识库文档") | ||
@RestController | ||
@RequestMapping("/ai/knowledge/document") | ||
@Validated | ||
public class AiKnowledgeDocumentController { | ||
|
||
@Resource | ||
private AiKnowledgeDocumentService documentService; | ||
|
||
@PostMapping("/create") | ||
@Operation(summary = "新建文档") | ||
public CommonResult<Long> createKnowledgeDocument(@Valid AiKnowledgeDocumentCreateReqVO reqVO) { | ||
Long knowledgeDocumentId = documentService.createKnowledgeDocument(reqVO); | ||
return success(knowledgeDocumentId); | ||
} | ||
|
||
@GetMapping("/page") | ||
@Operation(summary = "获取文档分页") | ||
public CommonResult<PageResult<AiKnowledgeDocumentRespVO>> getKnowledgeDocumentPageMy(@Valid AiKnowledgeDocumentPageReqVO pageReqVO) { | ||
PageResult<AiKnowledgeDocumentDO> pageResult = documentService.getKnowledgeDocumentPage(pageReqVO); | ||
return success(BeanUtils.toBean(pageResult, AiKnowledgeDocumentRespVO.class)); | ||
} | ||
|
||
@PutMapping("/update") | ||
@Operation(summary = "更新文档") | ||
public CommonResult<Boolean> updateKnowledgeDocument(@Valid @RequestBody AiKnowledgeDocumentUpdateReqVO reqVO) { | ||
documentService.updateKnowledgeDocument(reqVO); | ||
return success(true); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...a/cn/iocoder/yudao/module/ai/controller/admin/knowledge/AiKnowledgeSegmentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cn.iocoder.yudao.module.ai.controller.admin.knowledge; | ||
|
||
import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentPageReqVO; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentRespVO; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentUpdateReqVO; | ||
import cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.segment.AiKnowledgeSegmentUpdateStatusReqVO; | ||
import cn.iocoder.yudao.module.ai.dal.dataobject.knowledge.AiKnowledgeSegmentDO; | ||
import cn.iocoder.yudao.module.ai.service.knowledge.AiKnowledgeSegmentService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.annotation.Resource; | ||
import jakarta.validation.Valid; | ||
import org.springframework.validation.annotation.Validated; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
|
||
@Tag(name = "管理后台 - AI 知识库段落") | ||
@RestController | ||
@RequestMapping("/ai/knowledge/segment") | ||
@Validated | ||
public class AiKnowledgeSegmentController { | ||
|
||
@Resource | ||
private AiKnowledgeSegmentService segmentService; | ||
|
||
@GetMapping("/page") | ||
@Operation(summary = "获取段落分页") | ||
public CommonResult<PageResult<AiKnowledgeSegmentRespVO>> getKnowledgeSegmentPageMy(@Valid AiKnowledgeSegmentPageReqVO pageReqVO) { | ||
PageResult<AiKnowledgeSegmentDO> pageResult = segmentService.getKnowledgeSegmentPage(pageReqVO); | ||
return success(BeanUtils.toBean(pageResult, AiKnowledgeSegmentRespVO.class)); | ||
} | ||
|
||
@PutMapping("/update") | ||
@Operation(summary = "更新段落内容") | ||
public CommonResult<Boolean> updateKnowledgeSegment(@Valid @RequestBody AiKnowledgeSegmentUpdateReqVO reqVO) { | ||
segmentService.updateKnowledgeSegment(reqVO); | ||
return success(true); | ||
} | ||
|
||
@PutMapping("/update-status") | ||
@Operation(summary = "启禁用段落内容") | ||
public CommonResult<Boolean> updateKnowledgeSegmentStatus(@Valid @RequestBody AiKnowledgeSegmentUpdateStatusReqVO reqVO) { | ||
segmentService.updateKnowledgeSegmentStatus(reqVO); | ||
return success(true); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
.../yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentPageReqVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document; | ||
|
||
import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema(description = "管理后台 - AI 知识库文档的分页 Request VO") | ||
@Data | ||
public class AiKnowledgeDocumentPageReqVO extends PageParam { | ||
|
||
@Schema(description = "文档名称", example = "Java 开发手册") | ||
private String name; | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...der/yudao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentRespVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document; | ||
|
||
import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema(description = "管理后台 - AI 知识库-文档 Response VO") | ||
@Data | ||
public class AiKnowledgeDocumentRespVO extends PageParam { | ||
|
||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
private Long id; | ||
|
||
@Schema(description = "知识库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24790") | ||
private Long knowledgeId; | ||
|
||
@Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "Java 开发手册") | ||
private String name; | ||
|
||
@Schema(description = "内容", requiredMode = Schema.RequiredMode.REQUIRED, example = "Java 是一门面向对象的语言.....") | ||
private String content; | ||
|
||
@Schema(description = "文档 url", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://doc.iocoder.cn") | ||
private String url; | ||
|
||
@Schema(description = "token 数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
private Integer tokens; | ||
|
||
@Schema(description = "字符数", requiredMode = Schema.RequiredMode.REQUIRED, example = "1008") | ||
private Integer wordCount; | ||
|
||
@Schema(description = "切片状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
private Integer sliceStatus; | ||
|
||
@Schema(description = "文档状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
private Integer status; | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...udao/module/ai/controller/admin/knowledge/vo/document/AiKnowledgeDocumentUpdateReqVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.document; | ||
|
||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Data; | ||
|
||
|
||
@Schema(description = "管理后台 - AI 更新 知识库-文档 Request VO") | ||
@Data | ||
public class AiKnowledgeDocumentUpdateReqVO { | ||
|
||
|
||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "15583") | ||
@NotNull(message = "编号不能为空") | ||
private Long id; | ||
|
||
@Schema(description = "是否启用", example = "1") | ||
@InEnum(CommonStatusEnum.class) | ||
private Integer status; | ||
|
||
@Schema(description = "名称", example = "Java 开发手册") | ||
private String name; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...der/yudao/module/ai/controller/admin/knowledge/vo/knowledge/AiKnowledgeCreateMyReqVO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cn.iocoder.yudao.module.ai.controller.admin.knowledge.vo.knowledge; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Schema(description = "管理后台 - AI 知识库创建【我的】 Request VO") | ||
@Data | ||
public class AiKnowledgeCreateMyReqVO { | ||
|
||
@Schema(description = "知识库名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "ruoyi-vue-pro 用户指南") | ||
@NotBlank(message = "知识库名称不能为空") | ||
private String name; | ||
|
||
@Schema(description = "知识库描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "存储 ruoyi-vue-pro 操作文档") | ||
private String description; | ||
|
||
@Schema(description = "可见权限,只能选择哪些人可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1]") | ||
private List<Long> visibilityPermissions; | ||
|
||
@Schema(description = "嵌入模型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
@NotNull(message = "嵌入模型不能为空") | ||
private Long modelId; | ||
|
||
} |
Oops, something went wrong.