Skip to content
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

Add payload size limit #1151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add payload size limit #1151

wants to merge 2 commits into from

Conversation

yiwen101
Copy link
Contributor

@yiwen101 yiwen101 commented Aug 12, 2024

Closes #1150

@coveralls
Copy link

coveralls commented Aug 12, 2024

Coverage Status

coverage: 94.686% (+0.006%) from 94.68%
when pulling cbd7633 on payload_size_limit
into c2f659a on master.

lib/cadet_web/controllers/chat_controller.ex Outdated Show resolved Hide resolved
%{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

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
3 participants