Module ai.memory.mssql
ballerinax/ai.memory.mssql Ballerina library
Overview
This module provides an MS SQL-backed short-term memory store to use with AI messages (e.g., with AI agents, model providers, etc.).
Prerequisites
- Configuration for an MS SQL database
Quickstart
Follow the steps below to use this store in your Ballerina application:
- Import the
ballerinax/ai.memory.mssqlmodule.
import ballerinax/ai.memory.mssql;
Optionally, import the ballerina/ai and/or ballerinax/mssql module(s).
import ballerina/ai; import ballerinax/mssql;
-
Create the short-term memory store, by passing either the configuration for the database or an
mssql:Clientclient.i. Using the configuration
import ballerina/ai; import ballerinax/ai.memory.mssql; configurable string host = ?; configurable string user = ?; configurable string password = ?; configurable string database = ?; ai:ShortTermMemoryStore store = check new mssql:ShortTermMemoryStore({ host, user, password, database });ii. Using an
mssql:Clientclientimport ballerina/ai; import ballerinax/mssql; import ballerinax/ai.memory.mssql as mssqlStore; configurable string host = ?; configurable string user = ?; configurable string password = ?; configurable string database = ?; mssql:Client mssqlClient = check new (host, user, password, database); ai:ShortTermMemoryStore store = check new mssqlStore:ShortTermMemoryStore(mssqlClient);Optionally, specify the maximum number of messages to store per key (
maxMessagesPerKey- defaults to20) and/or the configuration for the in-memory cache for messages (cacheConfig- defaults to a capacity of20).ai:ShortTermMemoryStore store = check new mssql:ShortTermMemoryStore({ host, user, password, database }, 10, {capacity: 10});
Import
import ballerinax/ai.memory.mssql;Other versions
1.0.0