agentscope/examples/functionality/session_with_sqlite
xiaoxue 4060f1f09d 同步完整源码 - 2026-05-25 2026-05-25 01:46:32 +08:00
..
README.md 同步完整源码 - 2026-05-25 2026-05-25 01:46:32 +08:00
main.py 同步完整源码 - 2026-05-25 2026-05-25 01:46:32 +08:00
sqlite_session.py 同步完整源码 - 2026-05-25 2026-05-25 01:46:32 +08:00

README.md

Session Management with Sqlite DB

This example demonstrates how to implement session management with a database backend. We use SQLite for simplicity, but the approach can be adapted for other databases.

Specifically, we implement a SqliteSession class that persists and retrieves session data from a SQLite table. The table schema includes fields for session ID, session data (stored as JSON), and timestamps for creation and last update.

We will create a simple agent and chat with it, then store the session data in the SQLite database. Then in the test_load_session function, we will load the session data from the database and continue the chat.

Quick Start

Install agentscope from Pypi or source code.

pip install agentscope

Run the example by the following command

python main.py