流式输出,秒级,效果非常棒

This commit is contained in:
2026-03-31 21:06:59 +08:00
parent 279c28b412
commit fe7db4d4cf
3 changed files with 196 additions and 1 deletions

View File

@@ -12,8 +12,10 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@@ -62,6 +64,13 @@ public class AiQaItemController {
}
}
@PostMapping(value = "/askAIStream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@Operation(summary = "客户问答(大模型流式)", description = "流式返回大模型回答分片,流完成后自动落库")
public Flux<String> askCustomerStream(
@Parameter(description = "提问请求", required = true) @RequestBody AiQaCustomerAskRequestDto request) {
return aiQaCustomerAskService.askCustomerStream(request);
}
@PostMapping("/add")
@Operation(summary = "新增", description = "新增 AI 问答子表记录")
public ResponseEntity<Map<String, Object>> add(