| | |
| | | import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiModelPageReqVO; |
| | | import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiModelRespVO; |
| | | import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiModelSaveReqVO; |
| | | import cn.iocoder.yudao.module.ai.controller.admin.model.vo.model.AiModelUpdateStatusReqVO; |
| | | import cn.iocoder.yudao.module.ai.dal.dataobject.model.AiModelDO; |
| | | import cn.iocoder.yudao.module.ai.service.model.AiModelService; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/update-status") |
| | | @Operation(summary = "更新 AI 模型状态", description = "启用时会自动关闭同类型同能力的其他模型") |
| | | @PreAuthorize("@ss.hasPermission('ai:model:update')") |
| | | public CommonResult<Boolean> updateModelStatus(@Valid @RequestBody AiModelUpdateStatusReqVO updateReqVO) { |
| | | modelService.updateModelStatus(updateReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @Operation(summary = "删除 AI 模型") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | |
| | | @GetMapping("/simple-list") |
| | | @Operation(summary = "获得模型简单列表", description = "用于下拉选择器等场景") |
| | | @Parameter(name = "type", description = "模型类型", required = true, example = "1") |
| | | @Parameter(name = "capability", description = "模型能力:text-文本,vision-视觉", example = "text") |
| | | @Parameter(name = "platform", description = "模型平台", example = "TongYi") |
| | | public CommonResult<List<AiModelRespVO>> getModelSimpleList( |
| | | @RequestParam("type") Integer type, |
| | | @RequestParam(value = "capability", required = false) String capability, |
| | | @RequestParam(value = "platform", required = false) String platform) { |
| | | List<AiModelDO> list = modelService.getModelListByStatusAndType( |
| | | CommonStatusEnum.ENABLE.getStatus(), type, platform); |
| | | if (capability != null && !capability.isBlank()) { |
| | | list = list.stream().filter(model -> capability.equals(model.getCapability())).toList(); |
| | | } |
| | | return success(convertList(list, model -> new AiModelRespVO() |
| | | .setId(model.getId()) |
| | | .setName(model.getName()) |
| | | .setModel(model.getModel()) |
| | | .setPlatform(model.getPlatform()))); |
| | | .setPlatform(model.getPlatform()) |
| | | .setCapability(model.getCapability()))); |
| | | } |
| | | |
| | | } |