File tree Expand file tree Collapse file tree 4 files changed +8
-63
lines changed
java/com/javaaidev/webpageqa/chat Expand file tree Collapse file tree 4 files changed +8
-63
lines changed Original file line number Diff line number Diff line change 11package com .javaaidev .webpageqa .chat ;
22
3+ import org .springframework .ai .chat .client .ChatClient ;
34import org .springframework .web .bind .annotation .PostMapping ;
45import org .springframework .web .bind .annotation .RequestBody ;
56import org .springframework .web .bind .annotation .RestController ;
67
78@ RestController
89public class ChatController {
910
10- private final ChatService chatService ;
11+ private final ChatClient chatClient ;
1112
12- public ChatController (ChatService chatService ) {
13- this .chatService = chatService ;
13+ public ChatController (ChatClient chatClient ) {
14+ this .chatClient = chatClient ;
1415 }
1516
1617 @ PostMapping ("/chat" )
1718 public ChatResponse chat (@ RequestBody ChatRequest request ) {
18- return new ChatResponse (chatService . chat ( request ));
19+ return new ChatResponse (chatClient . prompt (). user ( request . input ()). call (). content ( ));
1920 }
2021}
Original file line number Diff line number Diff line change 11package com .javaaidev .webpageqa .chat ;
22
33import org .springframework .ai .chat .client .ChatClient ;
4+ import org .springframework .ai .chat .client .advisor .QuestionAnswerAdvisor ;
45import org .springframework .ai .vectorstore .VectorStore ;
56import org .springframework .context .annotation .Bean ;
67import org .springframework .context .annotation .Configuration ;
910public class ChatModuleConfiguration {
1011
1112 @ Bean
12- public ChatClient chatClient (ChatClient .Builder builder ) {
13- return builder .build ();
14- }
15-
16- @ Bean
17- public ChatService chatService (ChatClient chatClient ,
13+ public ChatClient chatClient (ChatClient .Builder builder ,
1814 VectorStore vectorStore ) {
19- return new ChatService ( chatClient , vectorStore );
15+ return builder . defaultAdvisors ( new QuestionAnswerAdvisor ( vectorStore )). build ( );
2016 }
2117}
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments