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

Strategy for caching session data/Short-term-memory #29

Open
simeonwetzel opened this issue Aug 12, 2024 · 1 comment
Open

Strategy for caching session data/Short-term-memory #29

simeonwetzel opened this issue Aug 12, 2024 · 1 comment
Assignees
Milestone

Comments

@simeonwetzel
Copy link
Collaborator

A strategy is needed to decide where session data (state) is stored (server side / client side). This applies to API responses as well as chat history.

@simeonwetzel
Copy link
Collaborator Author

Implemention details:

  1. Database initialization:
    The server initializes a SQLite database on startup:

    memory = AsyncSqliteSaver.from_conn_string(":memory:")

  2. Session creation:
    Each client must create a session by calling the create_session endpoint:
    curl -X POST http://localhost:8000/create_session

    async def create_session(response: Response):

This endpoint generates a session_id, which is then stored in a session cookie:
Image

  1. Session Management:
    When the langgraph state graph (chatbot) is initialized, the session_id is used to create a unique entry in the SQLite database. Each interaction with the graph (i.e., user input and AI response) results in a checkpoint being saved in the database. This checkpoint includes information such as:
  • Chat history
  • Search criteria
  • Spatial context
  • Search results
    This checkpoint functions as a form of short-term memory.
  1. Limitations and Benefits:
    Currently, checkpoints are not retained if the server is restarted. However, this approach allows different clients to maintain their own sessions and respective memories even when using a single SQLite database.

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

No branches or pull requests

1 participant