File tree Expand file tree Collapse file tree 2 files changed +31
-4
lines changed
backend/src/main/java/ch/xxx/aidoclibchat Expand file tree Collapse file tree 2 files changed +31
-4
lines changed Original file line number Diff line number Diff line change 1818import org .springframework .stereotype .Component ;
1919import org .springframework .web .client .RestClient ;
2020
21+ import ch .xxx .aidoclibchat .domain .client .TmdbClient ;
22+
2123@ Component
22- public class TmdbRestClient {
24+ public class TmdbRestClient implements TmdbClient {
2325 private static final Logger LOG = LoggerFactory .getLogger (TmdbRestClient .class );
2426 private static final String BASE_URL = "https://api.themoviedb.org/3/" ;
2527 private final RestClient restClient ;
@@ -29,16 +31,18 @@ public class TmdbRestClient {
2931 public TmdbRestClient (RestClient restClient ) {
3032 this .restClient = restClient ;
3133 }
32-
33- public void searchMovie (String query ) {
34- var url = BASE_URL + "search/movie?query=" + query ;
34+
35+ @ Override
36+ public Response apply (Request request ) {
37+ var url = BASE_URL + "search/movie?query=" + request .query ();
3538 var response = restClient .get ()
3639 .uri (url )
3740 .header ("accept" , "application/json" )
3841 .header ("Authorization" , "Bearer " +this .apiKey )
3942 .retrieve ()
4043 .body (String .class );
4144 LOG .info ("Response from TMDB: {}" , response );
45+ return new Response (response );
4246 }
4347
4448}
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/Interface.java to edit this template
4+ */
5+
6+ package ch .xxx .aidoclibchat .domain .client ;
7+
8+ import java .util .function .Function ;
9+
10+ import org .springframework .ai .tool .annotation .ToolParam ;
11+
12+ /**
13+ *
14+ * @author sven
15+ */
16+ public interface TmdbClient extends Function <TmdbClient .Request , TmdbClient .Response > {
17+
18+ record Request (@ ToolParam (description = "The movie title" ) String query ) {
19+ }
20+
21+ record Response (String response ) {
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments