Chapter 3: The model call
@Service
public class Assistant {
private final ChatClient chat;
public Assistant(ChatClient.Builder builder) {
this.chat = builder.build();
}
public String ask(String question) {
return chat.prompt()
.system("You are a careful assistant. Answer in two sentences or fewer.")
.user(question)
.call()
.content();
}
}
The ChatClient.Builder is created by Spring Boot when a model starter is on the classpath. The model replies in text. The client hides the request format.