dev
xiaohuo 8 months ago
parent 12fb40a5cc
commit 1160bc51de
  1. 9
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/LlmKnowledgeController/KnowLedgeController.java
  2. 5
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/LlmKnowledgeController/QAController.java
  3. 2
      ALOps_sys_backend/alops-chat/src/main/java/com/alops/chat/service/AItokenService.java

@ -4,11 +4,13 @@ import com.alops.chat.entity.KnowledgeEntity;
import com.alops.chat.entity.UploadedFile; import com.alops.chat.entity.UploadedFile;
import com.alops.chat.service.KnowledgeService; import com.alops.chat.service.KnowledgeService;
import com.alops.chat.service.UploadedFileService; import com.alops.chat.service.UploadedFileService;
import com.alops.common.annotation.Log;
import com.alops.common.constant.HttpStatus; import com.alops.common.constant.HttpStatus;
import com.alops.common.core.controller.BaseController; import com.alops.common.core.controller.BaseController;
import com.alops.common.core.domain.AjaxResult; import com.alops.common.core.domain.AjaxResult;
import com.alops.common.core.page.TableDataInfo; import com.alops.common.core.page.TableDataInfo;
import com.alops.common.config.RuoYiConfig; import com.alops.common.config.RuoYiConfig;
import com.alops.common.enums.BusinessType;
import com.alops.common.utils.file.FileUploadUtils; import com.alops.common.utils.file.FileUploadUtils;
import com.alops.common.utils.file.MimeTypeUtils; import com.alops.common.utils.file.MimeTypeUtils;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -61,6 +63,7 @@ public class KnowLedgeController extends BaseController {
@PreAuthorize("@ss.hasPermi('QandA:knowledge:uploadfile')") @PreAuthorize("@ss.hasPermi('QandA:knowledge:uploadfile')")
@PostMapping("/upload") @PostMapping("/upload")
@Log(title = "上传并处理文本文档", businessType = BusinessType.INSERT)
@ApiOperation("上传并处理文本文档") @ApiOperation("上传并处理文本文档")
public AjaxResult uploadFile( public AjaxResult uploadFile(
@RequestPart("file") @RequestPart("file")
@ -168,6 +171,7 @@ public class KnowLedgeController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('QandA:knowledge:upload')") @PreAuthorize("@ss.hasPermi('QandA:knowledge:upload')")
@PostMapping("/add-knowledge") @PostMapping("/add-knowledge")
@Log(title = "添加知识条目接口", businessType = BusinessType.INSERT)
@ApiOperation("添加知识条目接口") @ApiOperation("添加知识条目接口")
public AjaxResult addKnowledge( public AjaxResult addKnowledge(
@RequestParam String content, @RequestParam String content,
@ -189,6 +193,7 @@ public class KnowLedgeController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('QandA:knowledge:permquery')") @PreAuthorize("@ss.hasPermi('QandA:knowledge:permquery')")
@GetMapping("/permanent-knowledge") @GetMapping("/permanent-knowledge")
@Log(title = "获取所有正式知识条目", businessType = BusinessType.SELECT)
@ApiOperation("获取所有正式知识条目") @ApiOperation("获取所有正式知识条目")
public TableDataInfo getPermanentKnowledge() { public TableDataInfo getPermanentKnowledge() {
startPage(); // 开启分页 startPage(); // 开启分页
@ -203,6 +208,7 @@ public class KnowLedgeController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('QandA:knowledge:filelist')") @PreAuthorize("@ss.hasPermi('QandA:knowledge:filelist')")
@GetMapping("/uploaded-files") @GetMapping("/uploaded-files")
@Log(title = "获取所有上传文档", businessType = BusinessType.SELECT)
@ApiOperation("获取所有上传文档") @ApiOperation("获取所有上传文档")
public TableDataInfo getUploadedFiles() { public TableDataInfo getUploadedFiles() {
startPage(); // 开启分页 startPage(); // 开启分页
@ -220,6 +226,7 @@ public class KnowLedgeController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('QandA:knowledge:update')") @PreAuthorize("@ss.hasPermi('QandA:knowledge:update')")
@PutMapping("/update-knowledge") @PutMapping("/update-knowledge")
@Log(title = "更新知识条目", businessType = BusinessType.INSERT)
@ApiOperation("更新知识条目") @ApiOperation("更新知识条目")
public AjaxResult updateKnowledge( public AjaxResult updateKnowledge(
@RequestParam Long id, @RequestParam Long id,
@ -246,6 +253,7 @@ public class KnowLedgeController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('QandA:knowledge:del')") @PreAuthorize("@ss.hasPermi('QandA:knowledge:del')")
@DeleteMapping("/knowledge/{id}") @DeleteMapping("/knowledge/{id}")
@Log(title = "删除知识条目接口", businessType = BusinessType.DELETE)
@ApiOperation("删除知识条目接口") @ApiOperation("删除知识条目接口")
public AjaxResult deleteKnowledge(@PathVariable Long id) { public AjaxResult deleteKnowledge(@PathVariable Long id) {
try { try {
@ -268,6 +276,7 @@ public class KnowLedgeController extends BaseController {
*/ */
@ApiOperation("删除上传文件信息") @ApiOperation("删除上传文件信息")
@PreAuthorize("@ss.hasPermi('QandA:knowledge:filedel')") @PreAuthorize("@ss.hasPermi('QandA:knowledge:filedel')")
@Log(title = "删除上传文件信息", businessType = BusinessType.DELETE)
@DeleteMapping("/uploaded-files/{id}") @DeleteMapping("/uploaded-files/{id}")
public AjaxResult deleteUploadedFile(@PathVariable Long id) { public AjaxResult deleteUploadedFile(@PathVariable Long id) {
try { try {

@ -1,17 +1,17 @@
package com.alops.web.controller.LlmKnowledgeController; package com.alops.web.controller.LlmKnowledgeController;
import com.alops.chat.DTO.AnswerResponse; import com.alops.chat.DTO.AnswerResponse;
import com.alops.chat.DTO.QuestionRequest; import com.alops.chat.DTO.QuestionRequest;
import com.alops.chat.entity.KnowledgeEntity; import com.alops.chat.entity.KnowledgeEntity;
import com.alops.chat.service.AItokenService; import com.alops.chat.service.AItokenService;
import com.alops.chat.service.KnowledgeService; import com.alops.chat.service.KnowledgeService;
import com.alops.common.annotation.Log;
import com.alops.common.core.domain.AjaxResult; import com.alops.common.core.domain.AjaxResult;
import com.alops.common.enums.BusinessType;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -49,6 +49,7 @@ public class QAController {
@PreAuthorize("@ss.hasPermi('QandA:Aiassistant:ask')") @PreAuthorize("@ss.hasPermi('QandA:Aiassistant:ask')")
@PostMapping("/ask") @PostMapping("/ask")
@ApiOperation("智能问答提问") @ApiOperation("智能问答提问")
@Log(title = "智能问答提问", businessType = BusinessType.INSERT)
public AjaxResult askQuestion(@RequestBody QuestionRequest request) { public AjaxResult askQuestion(@RequestBody QuestionRequest request) {
try { try {
// 检查是否使用假数据模式 // 检查是否使用假数据模式

@ -262,7 +262,7 @@ public class AItokenService {
requestBody.put("model", GENERATION_MODEL); requestBody.put("model", GENERATION_MODEL);
requestBody.put("messages", messages); requestBody.put("messages", messages);
requestBody.put("stream", false); requestBody.put("stream", false);
requestBody.put("options", Map.of("num_predict", 2048)); // 限制生成长度以减少资源消耗 requestBody.put("options", Map.of("num_predict", 8192)); // 限制生成长度以减少资源消耗
// 设置请求头 // 设置请求头
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();

Loading…
Cancel
Save