File tree 4 files changed +8
-63
lines changed
java/com/javaaidev/webpageqa/chat
4 files changed +8
-63
lines changed Original file line number Diff line number Diff line change 1
1
package com .javaaidev .webpageqa .chat ;
2
2
3
+ import org .springframework .ai .chat .client .ChatClient ;
3
4
import org .springframework .web .bind .annotation .PostMapping ;
4
5
import org .springframework .web .bind .annotation .RequestBody ;
5
6
import org .springframework .web .bind .annotation .RestController ;
6
7
7
8
@ RestController
8
9
public class ChatController {
9
10
10
- private final ChatService chatService ;
11
+ private final ChatClient chatClient ;
11
12
12
- public ChatController (ChatService chatService ) {
13
- this .chatService = chatService ;
13
+ public ChatController (ChatClient chatClient ) {
14
+ this .chatClient = chatClient ;
14
15
}
15
16
16
17
@ PostMapping ("/chat" )
17
18
public ChatResponse chat (@ RequestBody ChatRequest request ) {
18
- return new ChatResponse (chatService . chat ( request ));
19
+ return new ChatResponse (chatClient . prompt (). user ( request . input ()). call (). content ( ));
19
20
}
20
21
}
Original file line number Diff line number Diff line change 1
1
package com .javaaidev .webpageqa .chat ;
2
2
3
3
import org .springframework .ai .chat .client .ChatClient ;
4
+ import org .springframework .ai .chat .client .advisor .QuestionAnswerAdvisor ;
4
5
import org .springframework .ai .vectorstore .VectorStore ;
5
6
import org .springframework .context .annotation .Bean ;
6
7
import org .springframework .context .annotation .Configuration ;
9
10
public class ChatModuleConfiguration {
10
11
11
12
@ 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 ,
18
14
VectorStore vectorStore ) {
19
- return new ChatService ( chatClient , vectorStore );
15
+ return builder . defaultAdvisors ( new QuestionAnswerAdvisor ( vectorStore )). build ( );
20
16
}
21
17
}
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments