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

Enabling RAG makes it relatively easy to reach 400KB limit for a dynamodb item on sessions table #580

Open
gbone-restore opened this issue Sep 26, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@gbone-restore
Copy link

Amazon DynamoDB limits the size of each item in a table to 400 KB. It's feasible that this limit could be reached on the sessions table because of all the extra metadata stored in the item. Especially when running with RAG configured. The session table stores chat history in a single item attribute.

To work around this limitation, we can store chat history as individual items in the sessions table. I can submit a PR for this change if there is an interest in this issue.

@gbone-restore gbone-restore changed the title Enabling RAG makes it relatively easy to reach dynamodb item limits on sessions table. Enabling RAG makes it relatively easy to reach 400KB limit for a dynamodb item on sessions table Sep 27, 2024
@charles-marion charles-marion added the bug Something isn't working label Oct 9, 2024
@charles-marion
Copy link
Collaborator

Hi @gbone-restore ,

I agree it is an issue but changing the table structure might be a significant change.

A shorter/smaller change could be to reduce the metadata stored and limit the number of message in the sessions.

@gbone-restore
Copy link
Author

Here's the data model that I used to test out this change.

Sessions

The partition key is now users and the sort key is sessions. And there are two types of items to make selecting session history and dealing with chat history a little easier. I can submit a PR with a working example. The bulk of the changes are in lib/shared/layers/python-sdk/python/genai_core/langchain/chat_message_history.py and lib/shared/layers/python-sdk/python/genai_core/sessions.py.

@charles-marion
Copy link
Collaborator

charles-marion commented Oct 10, 2024

The partition key is now users and the sort key is sessions.

I think it's a good solution. My concern is it would invalidate existing sessions

I can submit a PR with a working example

If you already have a prototype available it would be welcome.

Note I intend to discuss this topic with the maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

2 participants