feat(core): 改用amis推荐的返回结构

This commit is contained in:
v-zhangjc9
2025-05-27 09:35:11 +08:00
parent e57c81ce75
commit f7ed3bd270
5 changed files with 216 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
package com.lanyuanxiaoyao.service.ai.knowledge.controller;
import com.lanyuanxiaoyao.service.ai.knowledge.entity.vo.KnowledgeVO;
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisMapResponse;
import com.lanyuanxiaoyao.service.ai.core.entity.amis.AmisResponse;
import com.lanyuanxiaoyao.service.ai.knowledge.entity.vo.PointVO;
import com.lanyuanxiaoyao.service.ai.knowledge.service.EmbeddingService;
import com.lanyuanxiaoyao.service.ai.knowledge.service.KnowledgeService;
@@ -56,8 +57,8 @@ public class KnowledgeController {
}
@GetMapping("list")
public ImmutableList<KnowledgeVO> list() {
return knowledgeService.list();
public AmisResponse<?> list() {
return AmisResponse.responseCrudData(knowledgeService.list());
}
@GetMapping("list_points")
@@ -89,19 +90,20 @@ public class KnowledgeController {
}
@PostMapping("preview_text")
public ImmutableList<PointVO> previewText(
public AmisResponse<?> previewText(
@RequestParam(value = "mode", defaultValue = "NORMAL") String mode,
@RequestParam(value = "type", defaultValue = "text") String type,
@RequestParam("content") String content
) {
return embeddingService.split(mode, content)
.collect(doc -> {
PointVO vo = new PointVO();
vo.setId(doc.getId());
vo.setText(doc.getText());
return vo;
})
.toImmutable();
return AmisResponse.responseCrudData(
embeddingService.split(mode, content)
.collect(doc -> {
PointVO vo = new PointVO();
vo.setId(doc.getId());
vo.setText(doc.getText());
return vo;
})
);
}
@PostMapping(value = "process_text", consumes = "text/plain;charset=utf-8")