-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(core): Add byte size limit and oldest first truncation for gen_ai messages #17863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing 🎉 ! Let's address some comments before merging this
// For models.generateContent: ContentListUnion: Content | Content[] | PartUnion | PartUnion[] | ||
if ('contents' in params) { | ||
span.setAttributes({ [GEN_AI_REQUEST_MESSAGES_ATTRIBUTE]: JSON.stringify(params.contents) }); | ||
const contents = params.contents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you revert the comment removal to help others understand the request structure? this could also be a string
} | ||
|
||
// Extract and record AI request inputs, if present. This is intentionally separate from response attributes. | ||
function addRequestAttributes(span: Span, params: Record<string, unknown>): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also revert back this JSDoc comment?
6d97149
to
50d1d6d
Compare
@RulaKhaled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for resolving comments, it already looks better! I've pushed a quick commit for truncation functionality + added some JSDocs here :4d047e5 (this is a different branch) could you give this a shot? :) + can you take care of tests and the quick comments left?
3ab7059
to
c91de63
Compare
@RulaKhaled |
I pushed changes to truncation file to help get this to finish line, but i'm having issues pushing more from my local setup to this branch. Can you resolve the rest of unresolved comments please? to be clear:
I'll pick this up again on Monday, thanks for resolving the comments :) |
Description:
fixes: #17809
gen_ai.request.messages
andvercel.ai.prompt
to prevent oversized payloads from exceeding ingestion limits.Changes:
messageTruncation.ts
utility with byte size calculation and oldest-first truncation