File tree Expand file tree Collapse file tree
backend/src/main/java/ch/xxx/aidoclibchat Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313package ch .xxx .aidoclibchat .adapter .controller ;
1414
1515import org .springframework .web .bind .annotation .GetMapping ;
16+ import org .springframework .web .bind .annotation .PathVariable ;
1617import org .springframework .web .bind .annotation .RequestMapping ;
1718import org .springframework .web .bind .annotation .RestController ;
1819
20+ import ch .xxx .aidoclibchat .domain .model .dto .SiteSummaryDto ;
1921import ch .xxx .aidoclibchat .usecase .service .SiteSummaryService ;
2022
2123@ RestController
@@ -28,7 +30,7 @@ public SiteSummaryController(SiteSummaryService siteSummaryService) {
2830 }
2931
3032 @ GetMapping ("/joke-about/{topic}" )
31- public String getJokeAboutTopic (String topic ) {
33+ public SiteSummaryDto getJokeAboutTopic (@ PathVariable String topic ) {
3234 return this .siteSummaryService .getJokeAboutTopic (topic );
3335 }
3436}
Original file line number Diff line number Diff line change 2828@ RestController
2929@ RequestMapping ("rest/table" )
3030public class TableController {
31- private TableMapper tableMapper ;
32- private TableService tableService ;
31+ private final TableMapper tableMapper ;
32+ private final TableService tableService ;
3333
3434 public TableController (TableMapper tableMapper , TableService tableService ) {
3535 this .tableMapper = tableMapper ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Record.java to edit this template
4+ */
5+
6+ package ch .xxx .aidoclibchat .domain .model .dto ;
7+
8+ /**
9+ *
10+ * @author sven
11+ */
12+ public record SiteSummaryDto (String summary ) { }
Original file line number Diff line number Diff line change 1212 */
1313package ch .xxx .aidoclibchat .usecase .service ;
1414
15+ import org .springframework .ai .chat .client .ChatClient ;
16+ import org .springframework .ai .chat .client .ChatClient .Builder ;
1517import org .springframework .stereotype .Service ;
1618
19+ import ch .xxx .aidoclibchat .domain .model .dto .SiteSummaryDto ;
20+
1721@ Service
1822public class SiteSummaryService {
19- public String getJokeAboutTopic (String topic ) {
20- // Placeholder implementation
21- return "Why did the " + topic + " go to the party? Because it wanted to have a blast!" ;
23+ private final ChatClient chatClient ;
24+
25+ private final String promptStr = """
26+ Tell me a joke about the following topic and put in in the summary property.
27+
28+ Topic:
29+
30+ """ ;
31+
32+ public SiteSummaryService (Builder builder ) {
33+ this .chatClient = builder .build ();
34+ }
35+
36+ public SiteSummaryDto getJokeAboutTopic (String topic ) {
37+ var result = this .chatClient .prompt (this .promptStr + topic ).call ().entity (SiteSummaryDto .class );
38+ return result ;
2239 }
2340}
You can’t perform that action at this time.
0 commit comments