From 2c63fb8547c675b6e0dd433881c934caa69eea92 Mon Sep 17 00:00:00 2001 From: Pavan Kumar <66913595+ascender1729@users.noreply.github.com> Date: Fri, 6 Jun 2025 21:15:12 +0530 Subject: [PATCH 1/2] Add SQLite conversation example --- .../sqlite_conversation.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/communication_examples/sqlite_conversation.py diff --git a/examples/communication_examples/sqlite_conversation.py b/examples/communication_examples/sqlite_conversation.py new file mode 100644 index 00000000..a1e06b05 --- /dev/null +++ b/examples/communication_examples/sqlite_conversation.py @@ -0,0 +1,25 @@ +from swarms import Agent +from swarms.communication.sqlite_wrap import SQLiteConversation + +# Configure a conversation store backed by SQLite +conversation_store = SQLiteConversation( + db_path="agent_history.db", + table_name="messages", + enable_logging=True, +) + +# Create an agent that leverages the SQLite-based memory +agent = Agent( + agent_name="SupportAgent", + system_prompt="You are a helpful assistant.", + model_name="gpt-4o-mini", + long_term_memory=conversation_store, + max_loops=1, + autosave=True, +) + +response = agent.run("How do I reset my password?") +print(response) + +# Show the conversation as stored in SQLite +print(conversation_store.to_dict()) From b6b5c4df2bb02bc2e88973f361ac179af9eddde8 Mon Sep 17 00:00:00 2001 From: Pavan Kumar <66913595+ascender1729@users.noreply.github.com> Date: Fri, 6 Jun 2025 21:45:04 +0530 Subject: [PATCH 2/2] Update SQLite conversation example --- examples/communication_examples/sqlite_conversation.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/communication_examples/sqlite_conversation.py b/examples/communication_examples/sqlite_conversation.py index a1e06b05..312f99a9 100644 --- a/examples/communication_examples/sqlite_conversation.py +++ b/examples/communication_examples/sqlite_conversation.py @@ -1,3 +1,9 @@ +"""Persist agent dialogue using SQLiteConversation. + +Run `pip install -e .` in the repository root so the ``swarms`` package is +available before executing this script. +""" + from swarms import Agent from swarms.communication.sqlite_wrap import SQLiteConversation @@ -15,7 +21,9 @@ agent = Agent( model_name="gpt-4o-mini", long_term_memory=conversation_store, max_loops=1, - autosave=True, + # Autosave attempts to call `save()` on the memory object which is not + # implemented in SQLiteConversation, so we disable it for this example. + autosave=False, ) response = agent.run("How do I reset my password?")