This connector uses Redis to implement Semantic Memory. It requires the RediSearch module to be enabled on Redis to implement vector similarity search.
RediSearch is a source-available Redis module that enables querying, secondary indexing, and full-text search for Redis. These features enable multi-field queries, aggregation, exact phrase matching, numeric filtering, geo filtering and vector similarity semantic search on top of text queries.
Ways to get RediSearch:
-
You can create an Azure Cache for Redis Enterpise instance and enable RediSearch module.
-
Set up the RediSearch on your self-managed Redis, please refer to its documentation.
-
Use the Redis Enterprise, see Azure Marketplace, AWS Marketplace, or Google Marketplace.
- Run with Docker:
docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest
- To use Redis as a semantic memory store:
See Example 14 and Example 15 for more memory usage examples with the kernel.
// ConnectionMultiplexer should be a singleton instance in your application, please consider to dispose of it when your application shuts down.
// See https://stackexchange.github.io/StackExchange.Redis/Basics#basic-usage
ConnectionMultiplexer connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync("localhost:6379");
IDatabase database = connectionMultiplexer.GetDatabase();
RedisMemoryStore memoryStore = new RedisMemoryStore(database, vectorSize: 1536);
var embeddingGenerator = new OpenAITextEmbeddingGenerationService("text-embedding-ada-002", apiKey);
SemanticTextMemory textMemory = new(memoryStore, embeddingGenerator);
var memoryPlugin = kernel.ImportPluginFromObject(new TextMemoryPlugin(textMemory));