Skip to content

Commit

Permalink
Use ChatClient.Builder to create ChatClient instances
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreroman committed May 27, 2024
1 parent cbfca28 commit 6e2d599
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,12 @@

package com.broadcom.tanzu.demos.springai101;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

@Bean
ChatClient chatClient(ChatClient.Builder builder) {
return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
class ChatV1Controller {
private final ChatClient chatClient;

ChatV1Controller(ChatClient chatClient) {
this.chatClient = chatClient;
ChatV1Controller(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder.build();
}

@GetMapping(value = "/chat/v1", produces = MediaType.TEXT_PLAIN_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class ChatV2Controller {
@Value("classpath:/system-chat.st")
private Resource sysText;

ChatV2Controller(ChatClient chatClient) {
this.chatClient = chatClient;
ChatV2Controller(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder.build();
}

@GetMapping(value = "/chat/v2", produces = MediaType.TEXT_PLAIN_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
class WeatherV1Controller {
private final ChatClient chatClient;

WeatherV1Controller(ChatClient chatClient) {
this.chatClient = chatClient;
WeatherV1Controller(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder.build();
}

@GetMapping(value = "/weather/v1", produces = MediaType.TEXT_PLAIN_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
class WeatherV2Controller {
private final ChatClient chatClient;

WeatherV2Controller(ChatClient chatClient) {
this.chatClient = chatClient;
WeatherV2Controller(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder.build();
}

@GetMapping(value = "/weather/v2", produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
class WeatherV3Controller {
private final ChatClient chatClient;

WeatherV3Controller(ChatClient chatClient) {
this.chatClient = chatClient;
WeatherV3Controller(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder.build();
}

@GetMapping(value = "/weather/v3", produces = MediaType.TEXT_PLAIN_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
class WeatherV4Controller {
private final ChatClient chatClient;

WeatherV4Controller(ChatClient chatClient) {
this.chatClient = chatClient;
WeatherV4Controller(ChatClient.Builder chatClientBuilder) {
this.chatClient = chatClientBuilder.build();
}

@GetMapping(value = "/weather/v4", produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down

0 comments on commit 6e2d599

Please sign in to comment.