ui: simplify DDS knowledge registration
This commit is contained in:
@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Controller
|
||||
public class DdsVectorKnowledgeController {
|
||||
|
||||
@@ -34,28 +36,38 @@ public class DdsVectorKnowledgeController {
|
||||
|
||||
@PostMapping("/vector-knowledge/ingest")
|
||||
public String ingest(
|
||||
@RequestParam String documentId,
|
||||
@RequestParam(required = false, defaultValue = "") String documentId,
|
||||
@RequestParam String title,
|
||||
@RequestParam(required = false, defaultValue = "") String sourceUri,
|
||||
@RequestParam String content,
|
||||
@RequestParam String techTags,
|
||||
@RequestParam(defaultValue = "600") int chunkSize,
|
||||
@RequestParam(defaultValue = "DEMO") String embeddingMode,
|
||||
@RequestParam(defaultValue = "false") boolean replaceExisting,
|
||||
RedirectAttributes redirectAttributes
|
||||
) {
|
||||
try {
|
||||
var result = service.ingest(new VectorIngestCommand(
|
||||
documentId, title, sourceUri, content, techTags, chunkSize, embeddingMode));
|
||||
resolveDocumentId(documentId, replaceExisting), title, sourceUri, content, techTags, chunkSize, embeddingMode));
|
||||
redirectAttributes.addFlashAttribute("ingestResult", result);
|
||||
redirectAttributes.addFlashAttribute("message",
|
||||
result.chunkCount() + "개 청크를 저장했습니다. DDS 권한 평가용 태그 "
|
||||
+ result.tagCount() + "개가 연결되었습니다.");
|
||||
"지식자료를 등록하고 검색 준비를 완료했습니다.");
|
||||
} catch (Exception exception) {
|
||||
redirectAttributes.addFlashAttribute("errorMessage", exception.getMessage());
|
||||
}
|
||||
return "redirect:/vector-knowledge";
|
||||
}
|
||||
|
||||
private String resolveDocumentId(String documentId, boolean replaceExisting) {
|
||||
if (documentId == null || documentId.isBlank()) {
|
||||
return "knowledge-" + UUID.randomUUID();
|
||||
}
|
||||
if (!replaceExisting) {
|
||||
throw new AppException("기존 자료를 교체하려면 교체 확인을 선택하세요.");
|
||||
}
|
||||
return documentId.trim();
|
||||
}
|
||||
|
||||
@PostMapping("/vector-knowledge/search")
|
||||
public String search(
|
||||
@RequestParam String userKey,
|
||||
|
||||
Reference in New Issue
Block a user