mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-14 12:23:39 +00:00
feat(知识库): 增加知识库模块
This commit is contained in:
@@ -17,7 +17,9 @@ import org.ruoyi.common.core.exception.base.BaseException;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.common.satoken.utils.LoginHelper;
|
||||
import org.ruoyi.knowledge.service.EmbeddingService;
|
||||
import org.ruoyi.system.domain.bo.ChatMessageBo;
|
||||
import org.ruoyi.system.domain.request.translation.TranslationRequest;
|
||||
import org.ruoyi.system.domain.vo.ChatMessageVo;
|
||||
import org.ruoyi.system.service.IChatMessageService;
|
||||
import org.ruoyi.system.service.ISseService;
|
||||
@@ -46,12 +48,16 @@ public class ChatController {
|
||||
|
||||
private final IChatMessageService chatMessageService;
|
||||
|
||||
private final EmbeddingService embeddingService;
|
||||
/**
|
||||
* 聊天接口
|
||||
*/
|
||||
@PostMapping("/send")
|
||||
@ResponseBody
|
||||
public SseEmitter sseChat(@RequestBody @Valid ChatRequest chatRequest, HttpServletRequest request) {
|
||||
if (chatRequest.getModel().startsWith("ollama")) {
|
||||
return ISseService.ollamaChat(chatRequest);
|
||||
}
|
||||
return ISseService.sseChat(chatRequest,request);
|
||||
}
|
||||
|
||||
@@ -89,6 +95,17 @@ public class ChatController {
|
||||
return ISseService.textToSpeed(textToSpeech);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本翻译
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
@PostMapping("/translation")
|
||||
@ResponseBody
|
||||
public String translation(@RequestBody TranslationRequest translationRequest) {
|
||||
return ISseService.translation(translationRequest);
|
||||
}
|
||||
|
||||
@PostMapping("/dall3")
|
||||
@ResponseBody
|
||||
public R<List<Item>> dall3(@RequestBody @Valid Dall3Request request) {
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package org.ruoyi.fusion.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.domain.R;
|
||||
import org.ruoyi.common.mybatis.core.page.PageQuery;
|
||||
import org.ruoyi.common.mybatis.core.page.TableDataInfo;
|
||||
import org.ruoyi.common.web.core.BaseController;
|
||||
import org.ruoyi.system.domain.vo.cover.CoverParamVo;
|
||||
import org.ruoyi.system.domain.vo.cover.CoverVo;
|
||||
import org.ruoyi.system.domain.vo.cover.CoverCallbackVo;
|
||||
import org.ruoyi.system.domain.vo.cover.MusicVo;
|
||||
import org.ruoyi.system.service.ICoverService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绘声美音-翻唱
|
||||
*
|
||||
* @author NSL
|
||||
* @since 2024-12-25
|
||||
*/
|
||||
@Api(tags = "歌曲翻唱")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cover")
|
||||
public class CoverController extends BaseController {
|
||||
|
||||
private final ICoverService coverService;
|
||||
|
||||
@ApiOperation(value = "查找歌曲")
|
||||
@GetMapping("/searchMusic")
|
||||
public R<List<MusicVo>> searchMusic(String musicName) {
|
||||
return R.ok(coverService.searchMusic(musicName));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "翻唱歌曲")
|
||||
@PostMapping("/saveCoverTask")
|
||||
public R<Void> saveCoverTask(@RequestBody CoverParamVo coverParamVo) {
|
||||
coverService.saveCoverTask(coverParamVo);
|
||||
return R.ok("翻唱歌曲处理中请等待10分钟-30分钟,翻唱结果请到翻唱记录中查询!");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询翻唱记录")
|
||||
@PostMapping("/searchCoverRecord")
|
||||
public R<TableDataInfo<CoverVo>> searchCoverRecord(@RequestBody PageQuery pageQuery) {
|
||||
return R.ok(coverService.searchCoverRecord(pageQuery));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "翻唱回调接口")
|
||||
@PostMapping("/callback")
|
||||
public R<Void> callback(@RequestBody CoverCallbackVo coverCallbackVo) {
|
||||
coverService.callback(coverCallbackVo);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ public class LumaController {
|
||||
@PostMapping("/generations/")
|
||||
public String generateVideo(@RequestBody GenerateLuma generateLuma) {
|
||||
OkHttpUtil okHttpUtil = okHttpConfig.getOkHttpUtil("luma");
|
||||
|
||||
chatCostService.taskDeduct("luma", "文生视频", NumberUtils.toDouble(okHttpConfig.getGenerate(), 0.3));
|
||||
String generateJson = JSONUtil.toJsonStr(generateLuma);
|
||||
String url = "luma/generations";
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package org.ruoyi.fusion.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.domain.R;
|
||||
import org.ruoyi.common.web.core.BaseController;
|
||||
import org.ruoyi.system.domain.vo.ppt.*;
|
||||
import org.ruoyi.system.service.IPptService;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
/**
|
||||
* AI_PPT
|
||||
*
|
||||
* @author NSL
|
||||
* @since 2024-12-30
|
||||
*/
|
||||
@Api(tags = "AI-PPT")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/ppt")
|
||||
public class PptController extends BaseController {
|
||||
|
||||
private final IPptService pptService;
|
||||
|
||||
@ApiOperation(value = "获取API Token")
|
||||
@GetMapping("/getApiToken")
|
||||
public R<String> getApiToken() {
|
||||
return R.ok(pptService.getApiToken());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "同步流式生成 PPT")
|
||||
@PostMapping("/syncStreamGeneratePpt")
|
||||
public R<Void> syncStreamGeneratePpt(String title) {
|
||||
pptService.syncStreamGeneratePpt(title);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询所有PPT列表")
|
||||
@PostMapping("/selectPptList")
|
||||
public R<Void> selectPptList(@RequestBody PptAllQueryDto pptQueryVo) {
|
||||
pptService.selectPptList(pptQueryVo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生成大纲")
|
||||
@PostMapping(value = "/generateOutline", produces = {MediaType.TEXT_EVENT_STREAM_VALUE})
|
||||
public SseEmitter generateOutline(@RequestBody PptGenerateOutlineDto generateOutlineDto) {
|
||||
return pptService.generateOutline(generateOutlineDto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生成大纲内容")
|
||||
@PostMapping(value = "/generateContent", produces = {MediaType.TEXT_EVENT_STREAM_VALUE})
|
||||
public SseEmitter generateOutline(@RequestBody PptGenerateContentDto generateContentDto) {
|
||||
return pptService.generateContent(generateContentDto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页查询 PPT 模板")
|
||||
@PostMapping("/getTemplates")
|
||||
public R<JSONObject> getPptTemplates(@RequestBody PptTemplateQueryDto pptQueryVo) {
|
||||
return R.ok(pptService.getPptTemplates(pptQueryVo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生成 PPT")
|
||||
@PostMapping("/generatePptx")
|
||||
public R<JSONObject> generatePptx(@RequestBody PptGeneratePptxDto pptQueryVo) {
|
||||
return R.ok(pptService.generatePptx(pptQueryVo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "生成PPT成功回调接口")
|
||||
@PostMapping("/successCallback")
|
||||
public R<Void> successCallback() {
|
||||
pptService.successCallback();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,19 @@
|
||||
package org.ruoyi.fusion.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.ruoyi.common.core.domain.R;
|
||||
import org.ruoyi.common.core.validate.EditGroup;
|
||||
import org.ruoyi.common.log.annotation.Log;
|
||||
import org.ruoyi.common.log.enums.BusinessType;
|
||||
import org.ruoyi.common.satoken.utils.LoginHelper;
|
||||
import org.ruoyi.common.web.core.BaseController;
|
||||
import org.ruoyi.system.domain.bo.VoiceRoleBo;
|
||||
import org.ruoyi.system.domain.vo.VoiceRoleVo;
|
||||
import org.ruoyi.system.request.RoleListDto;
|
||||
import org.ruoyi.system.request.RoleRequest;
|
||||
import org.ruoyi.system.request.SimpleGenerateRequest;
|
||||
import org.ruoyi.system.response.SimpleGenerateDataResponse;
|
||||
import org.ruoyi.system.response.rolelist.RoleListVO;
|
||||
import org.ruoyi.system.service.IVoiceRoleService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.ruoyi.system.response.rolelist.ChatAppStoreVO;
|
||||
import org.ruoyi.system.service.IChatAppStoreService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 配音角色
|
||||
* 应用市场
|
||||
*
|
||||
* @author Lion Li
|
||||
* @date 2024-03-19
|
||||
@@ -35,63 +23,7 @@ import java.util.List;
|
||||
@RequestMapping("/system/voice")
|
||||
public class VoiceController extends BaseController {
|
||||
|
||||
private final IVoiceRoleService voiceRoleService;
|
||||
|
||||
/**
|
||||
* 查询配音角色列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public List<VoiceRoleVo> list(VoiceRoleBo bo) {
|
||||
if(LoginHelper.getUserId() == null){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
bo.setCreateBy(LoginHelper.getUserId());
|
||||
return voiceRoleService.queryList(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取配音角色详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:role:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<VoiceRoleVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(voiceRoleService.queryById(id));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增配音角色
|
||||
*/
|
||||
@Log(title = "配音角色", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
public R<Void> add(@RequestBody RoleRequest roleRequest) {
|
||||
return toAjax(voiceRoleService.insertByBo(roleRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配音角色
|
||||
*/
|
||||
@SaCheckPermission("system:role:edit")
|
||||
@Log(title = "配音角色", businessType = BusinessType.UPDATE)
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody VoiceRoleBo bo) {
|
||||
return toAjax(voiceRoleService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配音角色
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@Log(title = "配音角色", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(voiceRoleService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
private final IChatAppStoreService voiceRoleService;
|
||||
|
||||
/**
|
||||
* 实时语音生成
|
||||
@@ -105,7 +37,7 @@ public class VoiceController extends BaseController {
|
||||
* 角色市场
|
||||
*/
|
||||
@GetMapping("/roleList")
|
||||
public R<List<RoleListVO>> roleList() {
|
||||
public R<List<ChatAppStoreVO>> roleList() {
|
||||
return R.ok(voiceRoleService.roleList());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user