添加知识库文档、知识库文档块和向量化存储的自动生成代码。
This commit is contained in:
parent
c77394fb8f
commit
238f93d4a2
@ -55,4 +55,12 @@ public interface ErrorCodeConstants {
|
||||
|
||||
ErrorCode DATASET_QUESTION_NOT_EXISTS = new ErrorCode(10025, "数据集数据问题不存在");
|
||||
|
||||
ErrorCode KNOWLEDGE_DOCUMENTS_NOT_EXISTS = new ErrorCode(10026, "知识库文档不存在");
|
||||
|
||||
ErrorCode KNOWLEDGE_DOCUMENTS_CHUNKS_NOT_EXISTS = new ErrorCode(10027, "知识库文档块不存在");
|
||||
|
||||
ErrorCode KNOWLEDGE_DOCUMENTS_CHUNKS_VECTORIZED_NOT_EXISTS = new ErrorCode(10028, "向量化存储不存在");
|
||||
|
||||
ErrorCode TRAINING_NOT_EXISTS = new ErrorCode(10029, "训练不存在");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocuments;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocuments.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocuments.KnowledgeDocumentsDO;
|
||||
import cn.iocoder.yudao.module.llm.service.knowledgedocuments.KnowledgeDocumentsService;
|
||||
|
||||
@Tag(name = "管理后台 - 知识库文档")
|
||||
@RestController
|
||||
@RequestMapping("/llm/knowledge-documents")
|
||||
@Validated
|
||||
public class KnowledgeDocumentsController {
|
||||
|
||||
@Resource
|
||||
private KnowledgeDocumentsService knowledgeDocumentsService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建知识库文档")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents:create')")
|
||||
public CommonResult<Long> createKnowledgeDocuments(@Valid @RequestBody KnowledgeDocumentsSaveReqVO createReqVO) {
|
||||
return success(knowledgeDocumentsService.createKnowledgeDocuments(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新知识库文档")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents:update')")
|
||||
public CommonResult<Boolean> updateKnowledgeDocuments(@Valid @RequestBody KnowledgeDocumentsSaveReqVO updateReqVO) {
|
||||
knowledgeDocumentsService.updateKnowledgeDocuments(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除知识库文档")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents:delete')")
|
||||
public CommonResult<Boolean> deleteKnowledgeDocuments(@RequestParam("id") Long id) {
|
||||
knowledgeDocumentsService.deleteKnowledgeDocuments(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得知识库文档")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents:query')")
|
||||
public CommonResult<KnowledgeDocumentsRespVO> getKnowledgeDocuments(@RequestParam("id") Long id) {
|
||||
KnowledgeDocumentsDO knowledgeDocuments = knowledgeDocumentsService.getKnowledgeDocuments(id);
|
||||
return success(BeanUtils.toBean(knowledgeDocuments, KnowledgeDocumentsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得知识库文档分页")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents:query')")
|
||||
public CommonResult<PageResult<KnowledgeDocumentsRespVO>> getKnowledgeDocumentsPage(@Valid KnowledgeDocumentsPageReqVO pageReqVO) {
|
||||
PageResult<KnowledgeDocumentsDO> pageResult = knowledgeDocumentsService.getKnowledgeDocumentsPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, KnowledgeDocumentsRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出知识库文档 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportKnowledgeDocumentsExcel(@Valid KnowledgeDocumentsPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<KnowledgeDocumentsDO> list = knowledgeDocumentsService.getKnowledgeDocumentsPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "知识库文档.xls", "数据", KnowledgeDocumentsRespVO.class,
|
||||
BeanUtils.toBean(list, KnowledgeDocumentsRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocuments.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 知识库文档分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class KnowledgeDocumentsPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "知识库ID", example = "18229")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档名称", example = "芋艿")
|
||||
private String documentName;
|
||||
|
||||
@Schema(description = "文件URL地址", example = "https://www.iocoder.cn")
|
||||
private String fileUrl;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "文件状态,使用字典(llm_file_status)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocuments.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 知识库文档 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class KnowledgeDocumentsRespVO {
|
||||
|
||||
@Schema(description = "知识库文档ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4847")
|
||||
@ExcelProperty("知识库文档ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "知识库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18229")
|
||||
@ExcelProperty("知识库ID")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档名称", example = "芋艿")
|
||||
@ExcelProperty("文档名称")
|
||||
private String documentName;
|
||||
|
||||
@Schema(description = "文件URL地址", example = "https://www.iocoder.cn")
|
||||
@ExcelProperty("文件URL地址")
|
||||
private String fileUrl;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "文件状态,使用字典(llm_file_status)", example = "1")
|
||||
@ExcelProperty("文件状态,使用字典(llm_file_status)")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocuments.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 知识库文档新增/修改 Request VO")
|
||||
@Data
|
||||
public class KnowledgeDocumentsSaveReqVO {
|
||||
|
||||
@Schema(description = "知识库文档ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4847")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "知识库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18229")
|
||||
@NotNull(message = "知识库ID不能为空")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档名称", example = "芋艿")
|
||||
private String documentName;
|
||||
|
||||
@Schema(description = "文件URL地址", example = "https://www.iocoder.cn")
|
||||
private String fileUrl;
|
||||
|
||||
@Schema(description = "文件状态,使用字典(llm_file_status)", example = "1")
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunks;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunks.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunks.KnowledgeDocumentsChunksDO;
|
||||
import cn.iocoder.yudao.module.llm.service.knowledgedocumentschunks.KnowledgeDocumentsChunksService;
|
||||
|
||||
@Tag(name = "管理后台 - 知识库文档块")
|
||||
@RestController
|
||||
@RequestMapping("/llm/knowledge-documents-chunks")
|
||||
@Validated
|
||||
public class KnowledgeDocumentsChunksController {
|
||||
|
||||
@Resource
|
||||
private KnowledgeDocumentsChunksService knowledgeDocumentsChunksService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建知识库文档块")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks:create')")
|
||||
public CommonResult<Long> createKnowledgeDocumentsChunks(@Valid @RequestBody KnowledgeDocumentsChunksSaveReqVO createReqVO) {
|
||||
return success(knowledgeDocumentsChunksService.createKnowledgeDocumentsChunks(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新知识库文档块")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks:update')")
|
||||
public CommonResult<Boolean> updateKnowledgeDocumentsChunks(@Valid @RequestBody KnowledgeDocumentsChunksSaveReqVO updateReqVO) {
|
||||
knowledgeDocumentsChunksService.updateKnowledgeDocumentsChunks(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除知识库文档块")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks:delete')")
|
||||
public CommonResult<Boolean> deleteKnowledgeDocumentsChunks(@RequestParam("id") Long id) {
|
||||
knowledgeDocumentsChunksService.deleteKnowledgeDocumentsChunks(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得知识库文档块")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks:query')")
|
||||
public CommonResult<KnowledgeDocumentsChunksRespVO> getKnowledgeDocumentsChunks(@RequestParam("id") Long id) {
|
||||
KnowledgeDocumentsChunksDO knowledgeDocumentsChunks = knowledgeDocumentsChunksService.getKnowledgeDocumentsChunks(id);
|
||||
return success(BeanUtils.toBean(knowledgeDocumentsChunks, KnowledgeDocumentsChunksRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得知识库文档块分页")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks:query')")
|
||||
public CommonResult<PageResult<KnowledgeDocumentsChunksRespVO>> getKnowledgeDocumentsChunksPage(@Valid KnowledgeDocumentsChunksPageReqVO pageReqVO) {
|
||||
PageResult<KnowledgeDocumentsChunksDO> pageResult = knowledgeDocumentsChunksService.getKnowledgeDocumentsChunksPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, KnowledgeDocumentsChunksRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出知识库文档块 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportKnowledgeDocumentsChunksExcel(@Valid KnowledgeDocumentsChunksPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<KnowledgeDocumentsChunksDO> list = knowledgeDocumentsChunksService.getKnowledgeDocumentsChunksPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "知识库文档块.xls", "数据", KnowledgeDocumentsChunksRespVO.class,
|
||||
BeanUtils.toBean(list, KnowledgeDocumentsChunksRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunks.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 知识库文档块分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class KnowledgeDocumentsChunksPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "知识库ID", example = "23286")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档ID", example = "12907")
|
||||
private Long documentId;
|
||||
|
||||
@Schema(description = "块ID", example = "27291")
|
||||
private Long chunkId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "向量数据")
|
||||
private byte[] vector;
|
||||
|
||||
@Schema(description = "文本块内容")
|
||||
private String content;
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunks.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 知识库文档块 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class KnowledgeDocumentsChunksRespVO {
|
||||
|
||||
@Schema(description = "知识库文档ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21673")
|
||||
@ExcelProperty("知识库文档ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "知识库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "23286")
|
||||
@ExcelProperty("知识库ID")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档ID", example = "12907")
|
||||
@ExcelProperty("文档ID")
|
||||
private Long documentId;
|
||||
|
||||
@Schema(description = "块ID", example = "27291")
|
||||
@ExcelProperty("块ID")
|
||||
private Long chunkId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "向量数据")
|
||||
@ExcelProperty("向量数据")
|
||||
private byte[] vector;
|
||||
|
||||
@Schema(description = "文本块内容")
|
||||
@ExcelProperty("文本块内容")
|
||||
private String content;
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunks.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 知识库文档块新增/修改 Request VO")
|
||||
@Data
|
||||
public class KnowledgeDocumentsChunksSaveReqVO {
|
||||
|
||||
@Schema(description = "知识库文档ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "21673")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "知识库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "23286")
|
||||
@NotNull(message = "知识库ID不能为空")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档ID", example = "12907")
|
||||
private Long documentId;
|
||||
|
||||
@Schema(description = "块ID", example = "27291")
|
||||
private Long chunkId;
|
||||
|
||||
@Schema(description = "向量数据")
|
||||
private byte[] vector;
|
||||
|
||||
@Schema(description = "文本块内容")
|
||||
private String content;
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunksvectorized;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunksvectorized.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunksvectorized.KnowledgeDocumentsChunksVectorizedDO;
|
||||
import cn.iocoder.yudao.module.llm.service.knowledgedocumentschunksvectorized.KnowledgeDocumentsChunksVectorizedService;
|
||||
|
||||
@Tag(name = "管理后台 - 向量化存储")
|
||||
@RestController
|
||||
@RequestMapping("/llm/knowledge-documents-chunks-vectorized")
|
||||
@Validated
|
||||
public class KnowledgeDocumentsChunksVectorizedController {
|
||||
|
||||
@Resource
|
||||
private KnowledgeDocumentsChunksVectorizedService knowledgeDocumentsChunksVectorizedService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建向量化存储")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks-vectorized:create')")
|
||||
public CommonResult<Long> createKnowledgeDocumentsChunksVectorized(@Valid @RequestBody KnowledgeDocumentsChunksVectorizedSaveReqVO createReqVO) {
|
||||
return success(knowledgeDocumentsChunksVectorizedService.createKnowledgeDocumentsChunksVectorized(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新向量化存储")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks-vectorized:update')")
|
||||
public CommonResult<Boolean> updateKnowledgeDocumentsChunksVectorized(@Valid @RequestBody KnowledgeDocumentsChunksVectorizedSaveReqVO updateReqVO) {
|
||||
knowledgeDocumentsChunksVectorizedService.updateKnowledgeDocumentsChunksVectorized(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除向量化存储")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks-vectorized:delete')")
|
||||
public CommonResult<Boolean> deleteKnowledgeDocumentsChunksVectorized(@RequestParam("id") Long id) {
|
||||
knowledgeDocumentsChunksVectorizedService.deleteKnowledgeDocumentsChunksVectorized(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得向量化存储")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks-vectorized:query')")
|
||||
public CommonResult<KnowledgeDocumentsChunksVectorizedRespVO> getKnowledgeDocumentsChunksVectorized(@RequestParam("id") Long id) {
|
||||
KnowledgeDocumentsChunksVectorizedDO knowledgeDocumentsChunksVectorized = knowledgeDocumentsChunksVectorizedService.getKnowledgeDocumentsChunksVectorized(id);
|
||||
return success(BeanUtils.toBean(knowledgeDocumentsChunksVectorized, KnowledgeDocumentsChunksVectorizedRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得向量化存储分页")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks-vectorized:query')")
|
||||
public CommonResult<PageResult<KnowledgeDocumentsChunksVectorizedRespVO>> getKnowledgeDocumentsChunksVectorizedPage(@Valid KnowledgeDocumentsChunksVectorizedPageReqVO pageReqVO) {
|
||||
PageResult<KnowledgeDocumentsChunksVectorizedDO> pageResult = knowledgeDocumentsChunksVectorizedService.getKnowledgeDocumentsChunksVectorizedPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, KnowledgeDocumentsChunksVectorizedRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出向量化存储 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('llm:knowledge-documents-chunks-vectorized:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportKnowledgeDocumentsChunksVectorizedExcel(@Valid KnowledgeDocumentsChunksVectorizedPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<KnowledgeDocumentsChunksVectorizedDO> list = knowledgeDocumentsChunksVectorizedService.getKnowledgeDocumentsChunksVectorizedPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "向量化存储.xls", "数据", KnowledgeDocumentsChunksVectorizedRespVO.class,
|
||||
BeanUtils.toBean(list, KnowledgeDocumentsChunksVectorizedRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunksvectorized.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 向量化存储分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class KnowledgeDocumentsChunksVectorizedPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "知识库ID", example = "12027")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档ID", example = "23414")
|
||||
private Long documentId;
|
||||
|
||||
@Schema(description = "块在文档中的索引")
|
||||
private Integer indexInDocument;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
@Schema(description = "文档块内容")
|
||||
private String chunkText;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunksvectorized.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 向量化存储 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class KnowledgeDocumentsChunksVectorizedRespVO {
|
||||
|
||||
@Schema(description = "知识库文档ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17820")
|
||||
@ExcelProperty("知识库文档ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "知识库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12027")
|
||||
@ExcelProperty("知识库ID")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档ID", example = "23414")
|
||||
@ExcelProperty("文档ID")
|
||||
private Long documentId;
|
||||
|
||||
@Schema(description = "块在文档中的索引")
|
||||
@ExcelProperty("块在文档中的索引")
|
||||
private Integer indexInDocument;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "文档块内容")
|
||||
@ExcelProperty("文档块内容")
|
||||
private String chunkText;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunksvectorized.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 向量化存储新增/修改 Request VO")
|
||||
@Data
|
||||
public class KnowledgeDocumentsChunksVectorizedSaveReqVO {
|
||||
|
||||
@Schema(description = "知识库文档ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17820")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "知识库ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12027")
|
||||
@NotNull(message = "知识库ID不能为空")
|
||||
private Long knowledgeBaseId;
|
||||
|
||||
@Schema(description = "文档ID", example = "23414")
|
||||
private Long documentId;
|
||||
|
||||
@Schema(description = "块在文档中的索引")
|
||||
private Integer indexInDocument;
|
||||
|
||||
@Schema(description = "文档块内容")
|
||||
private String chunkText;
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.training;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.training.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.training.TrainingDO;
|
||||
import cn.iocoder.yudao.module.llm.service.training.TrainingService;
|
||||
|
||||
@Tag(name = "管理后台 - 训练")
|
||||
@RestController
|
||||
@RequestMapping("/llm/training")
|
||||
@Validated
|
||||
public class TrainingController {
|
||||
|
||||
@Resource
|
||||
private TrainingService trainingService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建训练")
|
||||
@PreAuthorize("@ss.hasPermission('llm:training:create')")
|
||||
public CommonResult<Integer> createTraining(@Valid @RequestBody TrainingSaveReqVO createReqVO) {
|
||||
return success(trainingService.createTraining(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新训练")
|
||||
@PreAuthorize("@ss.hasPermission('llm:training:update')")
|
||||
public CommonResult<Boolean> updateTraining(@Valid @RequestBody TrainingSaveReqVO updateReqVO) {
|
||||
trainingService.updateTraining(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除训练")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('llm:training:delete')")
|
||||
public CommonResult<Boolean> deleteTraining(@RequestParam("id") Integer id) {
|
||||
trainingService.deleteTraining(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得训练")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('llm:training:query')")
|
||||
public CommonResult<TrainingRespVO> getTraining(@RequestParam("id") Integer id) {
|
||||
TrainingDO training = trainingService.getTraining(id);
|
||||
return success(BeanUtils.toBean(training, TrainingRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得训练分页")
|
||||
@PreAuthorize("@ss.hasPermission('llm:training:query')")
|
||||
public CommonResult<PageResult<TrainingRespVO>> getTrainingPage(@Valid TrainingPageReqVO pageReqVO) {
|
||||
PageResult<TrainingDO> pageResult = trainingService.getTrainingPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, TrainingRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出训练 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('llm:training:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportTrainingExcel(@Valid TrainingPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<TrainingDO> list = trainingService.getTrainingPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "训练.xls", "数据", TrainingRespVO.class,
|
||||
BeanUtils.toBean(list, TrainingRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.training.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 训练分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class TrainingPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "基座模型名称", example = "张三")
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "介绍", example = "你说的对")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "训练轮次")
|
||||
private Integer trainingEpochs;
|
||||
|
||||
@Schema(description = "启用Lora")
|
||||
private Boolean useLora;
|
||||
|
||||
@Schema(description = "训练批次")
|
||||
private Integer trainingBatchSize;
|
||||
|
||||
@Schema(description = "评估批次")
|
||||
private Integer evaluationBatchSize;
|
||||
|
||||
@Schema(description = "梯度累加步数")
|
||||
private Integer gradientAccumulationSteps;
|
||||
|
||||
@Schema(description = "使用GPU数量", example = "22492")
|
||||
private Integer gpuCount;
|
||||
|
||||
@Schema(description = "学习率")
|
||||
private BigDecimal learningRate;
|
||||
|
||||
@Schema(description = "最大长度")
|
||||
private Integer maxLength;
|
||||
|
||||
@Schema(description = "记录创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "记录更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.training.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
|
||||
@Schema(description = "管理后台 - 训练 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class TrainingRespVO {
|
||||
|
||||
@Schema(description = "自增ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11614")
|
||||
@ExcelProperty("自增ID")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "基座模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@ExcelProperty("基座模型名称")
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "介绍", example = "你说的对")
|
||||
@ExcelProperty("介绍")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "训练轮次", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("训练轮次")
|
||||
private Integer trainingEpochs;
|
||||
|
||||
@Schema(description = "启用Lora", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("启用Lora")
|
||||
private Boolean useLora;
|
||||
|
||||
@Schema(description = "训练批次", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("训练批次")
|
||||
private Integer trainingBatchSize;
|
||||
|
||||
@Schema(description = "评估批次", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("评估批次")
|
||||
private Integer evaluationBatchSize;
|
||||
|
||||
@Schema(description = "梯度累加步数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("梯度累加步数")
|
||||
private Integer gradientAccumulationSteps;
|
||||
|
||||
@Schema(description = "使用GPU数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "22492")
|
||||
@ExcelProperty("使用GPU数量")
|
||||
private Integer gpuCount;
|
||||
|
||||
@Schema(description = "学习率", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("学习率")
|
||||
private BigDecimal learningRate;
|
||||
|
||||
@Schema(description = "最大长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("最大长度")
|
||||
private Integer maxLength;
|
||||
|
||||
@Schema(description = "记录创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("记录创建时间")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "记录更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("记录更新时间")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package cn.iocoder.yudao.module.llm.controller.admin.training.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 训练新增/修改 Request VO")
|
||||
@Data
|
||||
public class TrainingSaveReqVO {
|
||||
|
||||
@Schema(description = "自增ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11614")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "基座模型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
|
||||
@NotEmpty(message = "基座模型名称不能为空")
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "介绍", example = "你说的对")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "训练轮次", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "训练轮次不能为空")
|
||||
private Integer trainingEpochs;
|
||||
|
||||
@Schema(description = "启用Lora", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "启用Lora不能为空")
|
||||
private Boolean useLora;
|
||||
|
||||
@Schema(description = "训练批次", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "训练批次不能为空")
|
||||
private Integer trainingBatchSize;
|
||||
|
||||
@Schema(description = "评估批次", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "评估批次不能为空")
|
||||
private Integer evaluationBatchSize;
|
||||
|
||||
@Schema(description = "梯度累加步数", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "梯度累加步数不能为空")
|
||||
private Integer gradientAccumulationSteps;
|
||||
|
||||
@Schema(description = "使用GPU数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "22492")
|
||||
@NotNull(message = "使用GPU数量不能为空")
|
||||
private Integer gpuCount;
|
||||
|
||||
@Schema(description = "学习率", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "学习率不能为空")
|
||||
private BigDecimal learningRate;
|
||||
|
||||
@Schema(description = "最大长度", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "最大长度不能为空")
|
||||
private Integer maxLength;
|
||||
|
||||
@Schema(description = "记录创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "记录创建时间不能为空")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Schema(description = "记录更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "记录更新时间不能为空")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocuments;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 知识库文档 DO
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@TableName("llm_knowledge_documents")
|
||||
@KeySequence("llm_knowledge_documents_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KnowledgeDocumentsDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 知识库文档ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 知识库ID
|
||||
*/
|
||||
private Long knowledgeBaseId;
|
||||
/**
|
||||
* 文档名称
|
||||
*/
|
||||
private String documentName;
|
||||
/**
|
||||
* 文件URL地址
|
||||
*/
|
||||
private String fileUrl;
|
||||
/**
|
||||
* 文件状态,使用字典(llm_file_status)
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunks;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 知识库文档块 DO
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@TableName("llm_knowledge_documents_chunks")
|
||||
@KeySequence("llm_knowledge_documents_chunks_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KnowledgeDocumentsChunksDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 知识库文档ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 知识库ID
|
||||
*/
|
||||
private Long knowledgeBaseId;
|
||||
/**
|
||||
* 文档ID
|
||||
*/
|
||||
private Long documentId;
|
||||
/**
|
||||
* 块ID
|
||||
*/
|
||||
private Long chunkId;
|
||||
/**
|
||||
* 向量数据
|
||||
*/
|
||||
private byte[] vector;
|
||||
/**
|
||||
* 文本块内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunksvectorized;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 向量化存储 DO
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@TableName("llm_knowledge_documents_chunks_vectorized")
|
||||
@KeySequence("llm_knowledge_documents_chunks_vectorized_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class KnowledgeDocumentsChunksVectorizedDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 知识库文档ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 知识库ID
|
||||
*/
|
||||
private Long knowledgeBaseId;
|
||||
/**
|
||||
* 文档ID
|
||||
*/
|
||||
private Long documentId;
|
||||
/**
|
||||
* 块在文档中的索引
|
||||
*/
|
||||
private Integer indexInDocument;
|
||||
/**
|
||||
* 文档块内容
|
||||
*/
|
||||
private String chunkText;
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.dataobject.training;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 训练 DO
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@TableName("llm_training")
|
||||
@KeySequence("llm_training_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TrainingDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 自增ID
|
||||
*/
|
||||
@TableId
|
||||
private Integer id;
|
||||
/**
|
||||
* 基座模型名称
|
||||
*/
|
||||
private String modelName;
|
||||
/**
|
||||
* 介绍
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 训练轮次
|
||||
*/
|
||||
private Integer trainingEpochs;
|
||||
/**
|
||||
* 启用Lora
|
||||
*/
|
||||
private Boolean useLora;
|
||||
/**
|
||||
* 训练批次
|
||||
*/
|
||||
private Integer trainingBatchSize;
|
||||
/**
|
||||
* 评估批次
|
||||
*/
|
||||
private Integer evaluationBatchSize;
|
||||
/**
|
||||
* 梯度累加步数
|
||||
*/
|
||||
private Integer gradientAccumulationSteps;
|
||||
/**
|
||||
* 使用GPU数量
|
||||
*/
|
||||
private Integer gpuCount;
|
||||
/**
|
||||
* 学习率
|
||||
*/
|
||||
private BigDecimal learningRate;
|
||||
/**
|
||||
* 最大长度
|
||||
*/
|
||||
private Integer maxLength;
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
private LocalDateTime createdAt;
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocuments;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocuments.KnowledgeDocumentsDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocuments.vo.*;
|
||||
|
||||
/**
|
||||
* 知识库文档 Mapper
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Mapper
|
||||
public interface KnowledgeDocumentsMapper extends BaseMapperX<KnowledgeDocumentsDO> {
|
||||
|
||||
default PageResult<KnowledgeDocumentsDO> selectPage(KnowledgeDocumentsPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<KnowledgeDocumentsDO>()
|
||||
.eqIfPresent(KnowledgeDocumentsDO::getKnowledgeBaseId, reqVO.getKnowledgeBaseId())
|
||||
.likeIfPresent(KnowledgeDocumentsDO::getDocumentName, reqVO.getDocumentName())
|
||||
.eqIfPresent(KnowledgeDocumentsDO::getFileUrl, reqVO.getFileUrl())
|
||||
.betweenIfPresent(KnowledgeDocumentsDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(KnowledgeDocumentsDO::getStatus, reqVO.getStatus())
|
||||
.orderByDesc(KnowledgeDocumentsDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocumentschunks;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunks.KnowledgeDocumentsChunksDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunks.vo.*;
|
||||
|
||||
/**
|
||||
* 知识库文档块 Mapper
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Mapper
|
||||
public interface KnowledgeDocumentsChunksMapper extends BaseMapperX<KnowledgeDocumentsChunksDO> {
|
||||
|
||||
default PageResult<KnowledgeDocumentsChunksDO> selectPage(KnowledgeDocumentsChunksPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<KnowledgeDocumentsChunksDO>()
|
||||
.eqIfPresent(KnowledgeDocumentsChunksDO::getKnowledgeBaseId, reqVO.getKnowledgeBaseId())
|
||||
.eqIfPresent(KnowledgeDocumentsChunksDO::getDocumentId, reqVO.getDocumentId())
|
||||
.eqIfPresent(KnowledgeDocumentsChunksDO::getChunkId, reqVO.getChunkId())
|
||||
.betweenIfPresent(KnowledgeDocumentsChunksDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(KnowledgeDocumentsChunksDO::getVector, reqVO.getVector())
|
||||
.eqIfPresent(KnowledgeDocumentsChunksDO::getContent, reqVO.getContent())
|
||||
.orderByDesc(KnowledgeDocumentsChunksDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocumentschunksvectorized;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunksvectorized.KnowledgeDocumentsChunksVectorizedDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunksvectorized.vo.*;
|
||||
|
||||
/**
|
||||
* 向量化存储 Mapper
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Mapper
|
||||
public interface KnowledgeDocumentsChunksVectorizedMapper extends BaseMapperX<KnowledgeDocumentsChunksVectorizedDO> {
|
||||
|
||||
default PageResult<KnowledgeDocumentsChunksVectorizedDO> selectPage(KnowledgeDocumentsChunksVectorizedPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<KnowledgeDocumentsChunksVectorizedDO>()
|
||||
.eqIfPresent(KnowledgeDocumentsChunksVectorizedDO::getKnowledgeBaseId, reqVO.getKnowledgeBaseId())
|
||||
.eqIfPresent(KnowledgeDocumentsChunksVectorizedDO::getDocumentId, reqVO.getDocumentId())
|
||||
.eqIfPresent(KnowledgeDocumentsChunksVectorizedDO::getIndexInDocument, reqVO.getIndexInDocument())
|
||||
.betweenIfPresent(KnowledgeDocumentsChunksVectorizedDO::getCreateTime, reqVO.getCreateTime())
|
||||
.eqIfPresent(KnowledgeDocumentsChunksVectorizedDO::getChunkText, reqVO.getChunkText())
|
||||
.orderByDesc(KnowledgeDocumentsChunksVectorizedDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.llm.dal.mysql.training;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.training.TrainingDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.training.vo.*;
|
||||
|
||||
/**
|
||||
* 训练 Mapper
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Mapper
|
||||
public interface TrainingMapper extends BaseMapperX<TrainingDO> {
|
||||
|
||||
default PageResult<TrainingDO> selectPage(TrainingPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<TrainingDO>()
|
||||
.likeIfPresent(TrainingDO::getModelName, reqVO.getModelName())
|
||||
.eqIfPresent(TrainingDO::getDescription, reqVO.getDescription())
|
||||
.eqIfPresent(TrainingDO::getTrainingEpochs, reqVO.getTrainingEpochs())
|
||||
.eqIfPresent(TrainingDO::getUseLora, reqVO.getUseLora())
|
||||
.eqIfPresent(TrainingDO::getTrainingBatchSize, reqVO.getTrainingBatchSize())
|
||||
.eqIfPresent(TrainingDO::getEvaluationBatchSize, reqVO.getEvaluationBatchSize())
|
||||
.eqIfPresent(TrainingDO::getGradientAccumulationSteps, reqVO.getGradientAccumulationSteps())
|
||||
.eqIfPresent(TrainingDO::getGpuCount, reqVO.getGpuCount())
|
||||
.eqIfPresent(TrainingDO::getLearningRate, reqVO.getLearningRate())
|
||||
.eqIfPresent(TrainingDO::getMaxLength, reqVO.getMaxLength())
|
||||
.eqIfPresent(TrainingDO::getCreatedAt, reqVO.getCreatedAt())
|
||||
.eqIfPresent(TrainingDO::getUpdatedAt, reqVO.getUpdatedAt())
|
||||
.orderByDesc(TrainingDO::getId));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.llm.service.knowledgedocuments;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocuments.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocuments.KnowledgeDocumentsDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 知识库文档 Service 接口
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
public interface KnowledgeDocumentsService {
|
||||
|
||||
/**
|
||||
* 创建知识库文档
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createKnowledgeDocuments(@Valid KnowledgeDocumentsSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新知识库文档
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateKnowledgeDocuments(@Valid KnowledgeDocumentsSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除知识库文档
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteKnowledgeDocuments(Long id);
|
||||
|
||||
/**
|
||||
* 获得知识库文档
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 知识库文档
|
||||
*/
|
||||
KnowledgeDocumentsDO getKnowledgeDocuments(Long id);
|
||||
|
||||
/**
|
||||
* 获得知识库文档分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 知识库文档分页
|
||||
*/
|
||||
PageResult<KnowledgeDocumentsDO> getKnowledgeDocumentsPage(KnowledgeDocumentsPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.llm.service.knowledgedocuments;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocuments.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocuments.KnowledgeDocumentsDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocuments.KnowledgeDocumentsMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 知识库文档 Service 实现类
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class KnowledgeDocumentsServiceImpl implements KnowledgeDocumentsService {
|
||||
|
||||
@Resource
|
||||
private KnowledgeDocumentsMapper knowledgeDocumentsMapper;
|
||||
|
||||
@Override
|
||||
public Long createKnowledgeDocuments(KnowledgeDocumentsSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
KnowledgeDocumentsDO knowledgeDocuments = BeanUtils.toBean(createReqVO, KnowledgeDocumentsDO.class);
|
||||
knowledgeDocumentsMapper.insert(knowledgeDocuments);
|
||||
// 返回
|
||||
return knowledgeDocuments.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateKnowledgeDocuments(KnowledgeDocumentsSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateKnowledgeDocumentsExists(updateReqVO.getId());
|
||||
// 更新
|
||||
KnowledgeDocumentsDO updateObj = BeanUtils.toBean(updateReqVO, KnowledgeDocumentsDO.class);
|
||||
knowledgeDocumentsMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteKnowledgeDocuments(Long id) {
|
||||
// 校验存在
|
||||
validateKnowledgeDocumentsExists(id);
|
||||
// 删除
|
||||
knowledgeDocumentsMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateKnowledgeDocumentsExists(Long id) {
|
||||
if (knowledgeDocumentsMapper.selectById(id) == null) {
|
||||
throw exception(KNOWLEDGE_DOCUMENTS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KnowledgeDocumentsDO getKnowledgeDocuments(Long id) {
|
||||
return knowledgeDocumentsMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<KnowledgeDocumentsDO> getKnowledgeDocumentsPage(KnowledgeDocumentsPageReqVO pageReqVO) {
|
||||
return knowledgeDocumentsMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.llm.service.knowledgedocumentschunks;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunks.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunks.KnowledgeDocumentsChunksDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 知识库文档块 Service 接口
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
public interface KnowledgeDocumentsChunksService {
|
||||
|
||||
/**
|
||||
* 创建知识库文档块
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createKnowledgeDocumentsChunks(@Valid KnowledgeDocumentsChunksSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新知识库文档块
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateKnowledgeDocumentsChunks(@Valid KnowledgeDocumentsChunksSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除知识库文档块
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteKnowledgeDocumentsChunks(Long id);
|
||||
|
||||
/**
|
||||
* 获得知识库文档块
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 知识库文档块
|
||||
*/
|
||||
KnowledgeDocumentsChunksDO getKnowledgeDocumentsChunks(Long id);
|
||||
|
||||
/**
|
||||
* 获得知识库文档块分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 知识库文档块分页
|
||||
*/
|
||||
PageResult<KnowledgeDocumentsChunksDO> getKnowledgeDocumentsChunksPage(KnowledgeDocumentsChunksPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.llm.service.knowledgedocumentschunks;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunks.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunks.KnowledgeDocumentsChunksDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocumentschunks.KnowledgeDocumentsChunksMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 知识库文档块 Service 实现类
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class KnowledgeDocumentsChunksServiceImpl implements KnowledgeDocumentsChunksService {
|
||||
|
||||
@Resource
|
||||
private KnowledgeDocumentsChunksMapper knowledgeDocumentsChunksMapper;
|
||||
|
||||
@Override
|
||||
public Long createKnowledgeDocumentsChunks(KnowledgeDocumentsChunksSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
KnowledgeDocumentsChunksDO knowledgeDocumentsChunks = BeanUtils.toBean(createReqVO, KnowledgeDocumentsChunksDO.class);
|
||||
knowledgeDocumentsChunksMapper.insert(knowledgeDocumentsChunks);
|
||||
// 返回
|
||||
return knowledgeDocumentsChunks.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateKnowledgeDocumentsChunks(KnowledgeDocumentsChunksSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateKnowledgeDocumentsChunksExists(updateReqVO.getId());
|
||||
// 更新
|
||||
KnowledgeDocumentsChunksDO updateObj = BeanUtils.toBean(updateReqVO, KnowledgeDocumentsChunksDO.class);
|
||||
knowledgeDocumentsChunksMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteKnowledgeDocumentsChunks(Long id) {
|
||||
// 校验存在
|
||||
validateKnowledgeDocumentsChunksExists(id);
|
||||
// 删除
|
||||
knowledgeDocumentsChunksMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateKnowledgeDocumentsChunksExists(Long id) {
|
||||
if (knowledgeDocumentsChunksMapper.selectById(id) == null) {
|
||||
throw exception(KNOWLEDGE_DOCUMENTS_CHUNKS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KnowledgeDocumentsChunksDO getKnowledgeDocumentsChunks(Long id) {
|
||||
return knowledgeDocumentsChunksMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<KnowledgeDocumentsChunksDO> getKnowledgeDocumentsChunksPage(KnowledgeDocumentsChunksPageReqVO pageReqVO) {
|
||||
return knowledgeDocumentsChunksMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.llm.service.knowledgedocumentschunksvectorized;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunksvectorized.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunksvectorized.KnowledgeDocumentsChunksVectorizedDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 向量化存储 Service 接口
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
public interface KnowledgeDocumentsChunksVectorizedService {
|
||||
|
||||
/**
|
||||
* 创建向量化存储
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createKnowledgeDocumentsChunksVectorized(@Valid KnowledgeDocumentsChunksVectorizedSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新向量化存储
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateKnowledgeDocumentsChunksVectorized(@Valid KnowledgeDocumentsChunksVectorizedSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除向量化存储
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteKnowledgeDocumentsChunksVectorized(Long id);
|
||||
|
||||
/**
|
||||
* 获得向量化存储
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 向量化存储
|
||||
*/
|
||||
KnowledgeDocumentsChunksVectorizedDO getKnowledgeDocumentsChunksVectorized(Long id);
|
||||
|
||||
/**
|
||||
* 获得向量化存储分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 向量化存储分页
|
||||
*/
|
||||
PageResult<KnowledgeDocumentsChunksVectorizedDO> getKnowledgeDocumentsChunksVectorizedPage(KnowledgeDocumentsChunksVectorizedPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.llm.service.knowledgedocumentschunksvectorized;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.knowledgedocumentschunksvectorized.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.knowledgedocumentschunksvectorized.KnowledgeDocumentsChunksVectorizedDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocumentschunksvectorized.KnowledgeDocumentsChunksVectorizedMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 向量化存储 Service 实现类
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class KnowledgeDocumentsChunksVectorizedServiceImpl implements KnowledgeDocumentsChunksVectorizedService {
|
||||
|
||||
@Resource
|
||||
private KnowledgeDocumentsChunksVectorizedMapper knowledgeDocumentsChunksVectorizedMapper;
|
||||
|
||||
@Override
|
||||
public Long createKnowledgeDocumentsChunksVectorized(KnowledgeDocumentsChunksVectorizedSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
KnowledgeDocumentsChunksVectorizedDO knowledgeDocumentsChunksVectorized = BeanUtils.toBean(createReqVO, KnowledgeDocumentsChunksVectorizedDO.class);
|
||||
knowledgeDocumentsChunksVectorizedMapper.insert(knowledgeDocumentsChunksVectorized);
|
||||
// 返回
|
||||
return knowledgeDocumentsChunksVectorized.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateKnowledgeDocumentsChunksVectorized(KnowledgeDocumentsChunksVectorizedSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateKnowledgeDocumentsChunksVectorizedExists(updateReqVO.getId());
|
||||
// 更新
|
||||
KnowledgeDocumentsChunksVectorizedDO updateObj = BeanUtils.toBean(updateReqVO, KnowledgeDocumentsChunksVectorizedDO.class);
|
||||
knowledgeDocumentsChunksVectorizedMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteKnowledgeDocumentsChunksVectorized(Long id) {
|
||||
// 校验存在
|
||||
validateKnowledgeDocumentsChunksVectorizedExists(id);
|
||||
// 删除
|
||||
knowledgeDocumentsChunksVectorizedMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateKnowledgeDocumentsChunksVectorizedExists(Long id) {
|
||||
if (knowledgeDocumentsChunksVectorizedMapper.selectById(id) == null) {
|
||||
throw exception(KNOWLEDGE_DOCUMENTS_CHUNKS_VECTORIZED_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public KnowledgeDocumentsChunksVectorizedDO getKnowledgeDocumentsChunksVectorized(Long id) {
|
||||
return knowledgeDocumentsChunksVectorizedMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<KnowledgeDocumentsChunksVectorizedDO> getKnowledgeDocumentsChunksVectorizedPage(KnowledgeDocumentsChunksVectorizedPageReqVO pageReqVO) {
|
||||
return knowledgeDocumentsChunksVectorizedMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.llm.service.training;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.training.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.training.TrainingDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 训练 Service 接口
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
public interface TrainingService {
|
||||
|
||||
/**
|
||||
* 创建训练
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Integer createTraining(@Valid TrainingSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新训练
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateTraining(@Valid TrainingSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除训练
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteTraining(Integer id);
|
||||
|
||||
/**
|
||||
* 获得训练
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 训练
|
||||
*/
|
||||
TrainingDO getTraining(Integer id);
|
||||
|
||||
/**
|
||||
* 获得训练分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 训练分页
|
||||
*/
|
||||
PageResult<TrainingDO> getTrainingPage(TrainingPageReqVO pageReqVO);
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package cn.iocoder.yudao.module.llm.service.training;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.iocoder.yudao.module.llm.controller.admin.training.vo.*;
|
||||
import cn.iocoder.yudao.module.llm.dal.dataobject.training.TrainingDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.iocoder.yudao.module.llm.dal.mysql.training.TrainingMapper;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.llm.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 训练 Service 实现类
|
||||
*
|
||||
* @author 华大大模型
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class TrainingServiceImpl implements TrainingService {
|
||||
|
||||
@Resource
|
||||
private TrainingMapper trainingMapper;
|
||||
|
||||
@Override
|
||||
public Integer createTraining(TrainingSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
TrainingDO training = BeanUtils.toBean(createReqVO, TrainingDO.class);
|
||||
trainingMapper.insert(training);
|
||||
// 返回
|
||||
return training.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTraining(TrainingSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateTrainingExists(updateReqVO.getId());
|
||||
// 更新
|
||||
TrainingDO updateObj = BeanUtils.toBean(updateReqVO, TrainingDO.class);
|
||||
trainingMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTraining(Integer id) {
|
||||
// 校验存在
|
||||
validateTrainingExists(id);
|
||||
// 删除
|
||||
trainingMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateTrainingExists(Integer id) {
|
||||
if (trainingMapper.selectById(id) == null) {
|
||||
throw exception(TRAINING_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrainingDO getTraining(Integer id) {
|
||||
return trainingMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<TrainingDO> getTrainingPage(TrainingPageReqVO pageReqVO) {
|
||||
return trainingMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocuments.KnowledgeDocumentsMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocumentschunks.KnowledgeDocumentsChunksMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.llm.dal.mysql.knowledgedocumentschunksvectorized.KnowledgeDocumentsChunksVectorizedMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.llm.dal.mysql.training.TrainingMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user