I'd like to report a typo in the Spring AI documentation section on Chat Client API "Default System Text with parameters."(https://docs.spring.io/spring-ai/reference/api/chatclient.html) Specifically, in the example for the Default System Text with parameters.

The current example contains extra parentheses after 'content' :

@RestController
class AIController {
    private final ChatClient chatClient
    AIController(ChatClient chatClient) {
        this.chatClient = chatClient;
    }
    @GetMapping("/ai")
    Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message, String voice) {
        return Map.of(
                "completion",
                chatClient.prompt()
                        .system(sp -> sp.param("voice", voice))
                        .user(message)
                        .call()
                        .content());
    }
}

However, based on my understanding, it should likely be : (After removing extra parentheses)

@RestController
class AIController {
    private final ChatClient chatClient
    AIController(ChatClient chatClient) {
        this.chatClient = chatClient;
    }
    @GetMapping("/ai")
    Map<String, String> completion(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message, String voice) {
        return Map.of(
                "completion",
                chatClient.prompt()
                        .system(sp -> sp.param("voice", voice))
                        .user(message)
                        .call()
                        .content();
    }
}

Comment From: devholic22

@AshwinKrishnaK I don't think this is wrong, because if you look at the code, it follows the Map.of format. According to Map.of("key", "value") method, key is "completion", value is chatClient.prompt().system(sp -> sp.param("voice", voice)).user(message).call().content().

If you look at the chatclient.adoc file, you will see a compilation exception if you follow your code :)

스크린샷 2024-06-28 오후 10 38 17