Skip to content

Conversation

@tzolov
Copy link
Contributor

@tzolov tzolov commented Nov 23, 2024

  • ChatGenerationMetadata provides Map for additional metadata
  • Add Builder interface and DefaultChatGenerationMetadataBuilder
  • Add DefaultChatGenerationMetadata implementation
  • Update all AI model implementations to use the new builder pattern
  • Deprecate ChatGenerationMetadata.from() factory method

Resolves #1805

- ChatGenerationMetadata provides Map for additional metadata
- Add Builder interface and DefaultChatGenerationMetadataBuilder
- Add DefaultChatGenerationMetadata implementation
- Update all AI model implementations to use the new builder pattern
- Deprecate ChatGenerationMetadata.from() factory method

Resolves spring-projects#1805
@tzolov tzolov added this to the 1.0.0-M5 milestone Nov 23, 2024
chunk.amazonBedrockInvocationMetrics());
chatGenerationMetadata = ChatGenerationMetadata.builder()
.finishReason(completionReason)
.metadata("usage", chunk.amazonBedrockInvocationMetrics())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "metrics" ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class BedrockUsage has AmazonBedrockInvocationMetrics getUsage() so maybe it is the other way around, the class name should change? Prob not that important as we will remove this on the switch to bedrock converse.

response.usage().outputTokens()));
chatGenerationMetadata = ChatGenerationMetadata.builder()
.finishReason(response.delta().stopReason())
.metadata("usage",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move all these common metadata keys to constants?

}
};
}
// /**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code can be deleted.

@markpollack markpollack self-assigned this Nov 25, 2024
@markpollack
Copy link
Member

removed commented out code and made other small changes.

merged in f388f53

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Chat Generation Metadata to allow addition of different AI model result/message specific (meta)data.

3 participants