File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
src/main/java/run/halo/live2d/chat Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -82,21 +82,20 @@ private Mono<ServerResponse> chatProcess(ServerRequest request) {
8282 );
8383 }
8484
85+
8586 private Flux <ServerSentEvent <ChatResult >> chatCompletion (ChatRequest body ) {
8687 return reactiveSettingFetcher .fetch ("aichat" , AiChatConfig .class )
87- .doOnNext (aiChatConfig -> ReactiveSecurityContextHolder .getContext ()
88+ .map (aiChatConfig -> ReactiveSecurityContextHolder .getContext ()
8889 .map (SecurityContext ::getAuthentication )
89- .doOnNext (authentication -> {
90+ .flatMapMany (authentication -> {
9091 if (!aiChatConfig .aiChatBaseSetting .isAnonymous && !isAuthenticated (
9192 authentication )) {
9293 throw new ResponseStatusException (HttpStatus .UNAUTHORIZED , "请先登录" );
9394 }
95+ String systemMessage = aiChatConfig .aiChatBaseSetting .systemMessage ;
96+ List <ChatMessage > messages = this .buildChatMessage (systemMessage , body );
97+ return aiChatService .streamChatCompletion (messages );
9498 }))
95- .map (aiChatConfig -> {
96- String systemMessage = aiChatConfig .aiChatBaseSetting .systemMessage ;
97- List <ChatMessage > messages = this .buildChatMessage (systemMessage , body );
98- return aiChatService .streamChatCompletion (messages );
99- })
10099 .flatMapMany (Flux ::from );
101100 }
102101
You can’t perform that action at this time.
0 commit comments