Expected Behavior

I would expect the ChatResponse to have the metadata populated, if possible, which it is in this case.

public ChatResponse call(Prompt prompt) {
        Anthropic3ChatBedrockApi.AnthropicChatRequest request = this.createRequest(prompt);
        Anthropic3ChatBedrockApi.AnthropicChatResponse response = this.anthropicChatApi.chatCompletion(request);
        return new ChatResponse(List.of(new Generation(((Anthropic3ChatBedrockApi.MediaContent)response.content().get(0)).text())), {something here that converts the metadata in response into a ChatResponseMetadata});
    }

Current Behavior

Currently there is no way to get usage data other than talking with Anthropic3ChatBedrockApi directly and not using the BedrockAnthropic3ChatModel class, this involves duplicating most of the code in the ChatModel class.

Context

I am trying to do simple chat completions with Sonnet and I need to know the input and output token counts. I can re-write the logic in the ChatModel class and directly use the API class but it seems wasteful. The lack of passing this metadata negates all the usefulness of this class for me.

Comment From: csterwa

Hello @bronwyn-damm - has this been resolved in more recent versions of Spring AI?

Comment From: bronwyn-damm

We are using the 1.0.0-SNAPSHOT version. Is there a newer version? If not, this is still occurring.