Skip to content

Add payload size limit #1151

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

Merged
merged 5 commits into from
Jun 13, 2025
Merged

Add payload size limit #1151

merged 5 commits into from
Jun 13, 2025

Conversation

yiwen101
Copy link
Contributor

@yiwen101 yiwen101 commented Aug 12, 2024

Closes #1150

@coveralls
Copy link

coveralls commented Aug 12, 2024

Coverage Status

coverage: 92.838% (+0.009%) from 92.829%
when pulling 84d293d on payload_size_limit
into f5f8890 on master.

%{conn: conn, conversation_id: conversation_id} do
assert conversation_id != nil
max_message_length = ChatController.max_content_length()
message_exceed_length = String.duplicate("a", max_message_length + 1)
Copy link
Member

Choose a reason for hiding this comment

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

Let's also add another testcase to test that String.duplicate("a", max_message_length) passes normally

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in later commit. However, in current setup the expected result is similar to the "conversation id does not match user id" case. Do you know how to fix this?

def render("conversation_init.json", %{
conversation_id: id,
last_message: last,
max_content_size: size
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking if there is a need to configure it this way (as opposed to hardcoding), but I am fine with this as well. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Minor nit: Can we combine the if into the with? See https://elixirforum.com/t/proper-way-of-handling-simple-booleans-in-with-statement/45556/4 for an example

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing me to this. Fixed

Copy link
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@RichDom2185 RichDom2185 enabled auto-merge (squash) June 13, 2025 09:43
@RichDom2185 RichDom2185 merged commit 0572fb0 into master Jun 13, 2025
1 check passed
@RichDom2185 RichDom2185 deleted the payload_size_limit branch June 13, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit LLM individual message payload size
4 participants