mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-03-14 05:33:42 +08:00
新增 ChatDto 数据传输对象,更新聊天接口以支持知识库功能,优化聊天服务逻辑,调整前端组件以提升用户体验。
This commit is contained in:
@@ -2,6 +2,7 @@ package com.zl.mjga.controller;
|
||||
|
||||
import com.zl.mjga.dto.PageRequestDto;
|
||||
import com.zl.mjga.dto.PageResponseDto;
|
||||
import com.zl.mjga.dto.ai.ChatDto;
|
||||
import com.zl.mjga.dto.ai.LlmQueryDto;
|
||||
import com.zl.mjga.dto.ai.LlmVm;
|
||||
import com.zl.mjga.exception.BusinessException;
|
||||
@@ -72,9 +73,9 @@ public class AiController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public Flux<String> chat(Principal principal, @RequestBody String userMessage) {
|
||||
public Flux<String> chat(Principal principal, @RequestBody ChatDto chatDto) {
|
||||
Sinks.Many<String> sink = Sinks.many().unicast().onBackpressureBuffer();
|
||||
TokenStream chat = aiChatService.chatPrecedenceLlmWith(principal.getName(), userMessage);
|
||||
TokenStream chat = aiChatService.chat(principal.getName(), chatDto);
|
||||
chat.onPartialResponse(
|
||||
text ->
|
||||
sink.tryEmitNext(
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.zl.mjga.repository.LibraryRepository;
|
||||
import com.zl.mjga.service.RagService;
|
||||
import com.zl.mjga.service.UploadService;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -34,16 +33,16 @@ public class LibraryController {
|
||||
|
||||
@GetMapping("/libraries")
|
||||
public List<Library> queryLibraries() {
|
||||
return libraryRepository.findAll().stream().sorted(
|
||||
Comparator.comparing(Library::getId).reversed()
|
||||
).toList();
|
||||
return libraryRepository.findAll().stream()
|
||||
.sorted(Comparator.comparing(Library::getId).reversed())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@GetMapping("/docs")
|
||||
public List<LibraryDoc> queryLibraryDocs(@RequestParam Long libraryId) {
|
||||
return libraryDocRepository.fetchByLibId(libraryId).stream().sorted(
|
||||
Comparator.comparing(LibraryDoc::getId).reversed()
|
||||
).toList();
|
||||
return libraryDocRepository.fetchByLibId(libraryId).stream()
|
||||
.sorted(Comparator.comparing(LibraryDoc::getId).reversed())
|
||||
.toList();
|
||||
}
|
||||
|
||||
@GetMapping("/segments")
|
||||
|
||||
Reference in New Issue
Block a user