ballerinax/ai.memory.mssql Ballerina library

1.0.0

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:

  1. Import the ballerinax/ai.memory.mssql module.
Copy
import ballerinax/ai.memory.mssql;

Optionally, import the ballerina/ai and/or ballerinax/mssql module(s).

Copy
import ballerina/ai;
import ballerinax/mssql;
  1. Create the short-term memory store, by passing either the configuration for the database or an mssql:Client client.

    i. Using the configuration

    Copy
    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:Client client

    Copy
    import 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 to 20) and/or the configuration for the in-memory cache for messages (cacheConfig - defaults to a capacity of 20).

    Copy
    ai:ShortTermMemoryStore store = check new mssql:ShortTermMemoryStore({
        host, user, password, database
    }, 10, {capacity: 10});

Import

import ballerinax/ai.memory.mssql;Copy

Other versions

1.0.0

Metadata

Released date: 4 days ago

Version: 1.0.0

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.12.0

GraalVM compatible: Yes


Pull count

Total: 6

Current verison: 6


Weekly downloads


Source repository


Keywords

ai

agent

memory


Contributors