Architecture overview
We are actively working to improve this documentation. The content you see here may be incomplete, subject to change, or may not fully reflect the current state of the feature. We appreciate your understanding as we continue to enhance our docs.
AI plugin provides the fundamental building blocks for AI-powered features, including:
- Annotations for controlling embedding generation
- Text chunking for handling large content
- Text embedding generation for semantic search
Core classes​
AIRecordData​
A modification class that adds AI specific data and behaviors to all Brightspot records.
- Automatically generates embeddings when records are saved
- Deletes embeddings when records are deleted
- Integrates with
VectorDatabasefor storage - Supports both new configuration (
@GenerateEmbedding) and legacy configuration (AskAIClient) - Handles text chunking before embedding generation
Whenever a record is saved, it follows these steps to generate an embedding:
- Checks if the record type should generate embeddings
- Chunks the content using
TextChunker - Generates embeddings for each chunk using
TextEmbeddingGenerator - Saves embeddings to the vector database
@GenerateEmbedding​
A type-level annotation that marks a class for automatic embedding generation. For example, this is how to make sure that an embedding is generated each time an article is saved:
1@GenerateEmbedding2public class Article extends Content {3private String title;4private String body;5}
@ExcludeFromEmbedding​
A field-level annotation that excludes specific fields from embedding generation. For example, this is how to exclude sensitive data from an embedding:
1@GenerateEmbedding2public class Article extends Content {3private String title;45@ExcludeFromEmbedding6private String internalId;7}
Common use cases are:
- Personally identifiable information (PII)
- Internal system identifiers
- Administrative metadata (creation dates, flags)
- Large binary data or encoded content
TextChunker​
An abstract base class for splitting text into smaller chunks suitable for embedding generation. Typical use might look like:
1List<String> chunks = TextChunker.get().chunk(2"This is a very long piece of text that needs to be split...",3countTokens,410);
TextEmbeddingGenerator​
An abstract base class for generating text embeddings (vector representations of text). Typical use might look like:
1TextEmbeddingGenerator generator = TextEmbeddingGenerator.get();2int tokens = generator.countTokens("This is some text");3float[] embedding = generator.generate("This is some text");
Typical configuration​
Configure the text chunker (optional)​
1com.brightspot.ai.AiPlugin/textChunker/class=com.example.MyTextChunker2com.brightspot.ai.AiPlugin/textChunker/option=...
Configure the text embedding generator​
1com.brightspot.ai.AiPlugin/textEmbeddingGenerator/class=com.example.MyTextEmbeddingGenerator2com.brightspot.ai.AiPlugin/textEmbeddingGenerator/option=...