CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/maven-com-embabel-agent--embabel-agent-rag-core

RAG (Retrieval-Augmented Generation) framework for the Embabel Agent platform providing content ingestion, chunking, hierarchical navigation, and semantic search capabilities

Overview
Eval results
Files

content-storage.mddocs/api-reference/

Content Storage API Reference

Repository interfaces for persisting and retrieving content elements, with support for chunking, embedding generation, and document lifecycle management.

Repository Information

Query repository state and capabilities.

ContentElementRepositoryInfo

Information about repository contents and capabilities.

interface ContentElementRepositoryInfo {
    /**
     * Number of chunks in repository
     */
    val chunkCount: Int

    /**
     * Number of root documents in repository
     */
    val documentCount: Int

    /**
     * Total number of content elements (all types)
     */
    val contentElementCount: Int

    /**
     * Whether repository stores embeddings
     */
    val hasEmbeddings: Boolean

    /**
     * Whether repository persists to disk/database
     */
    val isPersistent: Boolean
}

Properties:

  • chunkCount: Number of chunks stored
  • documentCount: Number of root documents
  • contentElementCount: Total elements of all types
  • hasEmbeddings: True if embeddings are stored
  • isPersistent: True if data persists across restarts

Basic Repository Operations

Core storage and retrieval operations for content elements.

ContentElementRepository

Base repository interface for content elements.

interface ContentElementRepository : Named {
    /**
     * Repository name
     */
    override val name: String

    /**
     * Initialize repository storage
     */
    fun provision()

    /**
     * Get repository information
     * @return Information about repository state
     */
    fun info(): ContentElementRepositoryInfo

    /**
     * Save a content element
     * @param element Element to save
     * @return Saved element (may include generated fields)
     */
    fun save(element: ContentElement): ContentElement

    /**
     * Find element by ID
     * @param id Element identifier
     * @return Element or null if not found
     */
    fun findById(id: String): ContentElement?

    /**
     * Find all elements of a specific type
     * @param clazz Element class
     * @return Iterable of matching elements
     */
    fun <C : ContentElement> findAll(clazz: Class<C>): Iterable<C>

    /**
     * Find multiple chunks by IDs
     * @param chunkIds List of chunk identifiers
     * @return Iterable of found chunks
     */
    fun findAllChunksById(chunkIds: List<String>): Iterable<Chunk>

    /**
     * Find chunks associated with an entity
     * @param entityId Entity identifier
     * @return List of related chunks
     */
    fun findChunksForEntity(entityId: String): List<Chunk>

    /**
     * Get path from root to element
     * @param element Hierarchical content element
     * @return List of IDs from root to element, or null
     */
    fun pathFromRoot(element: HierarchicalContentElement): List<String>?
}

Properties:

  • name: Repository identifier

Methods:

  • provision(): Initialize storage (create tables, indexes, etc.)
  • info(): Get repository statistics
  • save(): Persist content element
  • findById(): Retrieve by ID
  • findAll(): Get all elements of type
  • findAllChunksById(): Batch retrieve chunks
  • findChunksForEntity(): Get chunks related to entity
  • pathFromRoot(): Get ancestry path

Chunking Repository

Repository with document chunking and lifecycle management.

ChunkingContentElementRepository

Repository that can chunk documents and manage document lifecycle.

interface ChunkingContentElementRepository : ContentElementRepository {
    /**
     * Enhancers applied to retrievables before storage
     */
    val enhancers: List<RetrievableEnhancer>

    /**
     * Write document and generate chunks
     * @param root Navigable document to process
     * @return List of chunk IDs created
     */
    fun writeAndChunkDocument(root: NavigableDocument): List<String>

    /**
     * Delete document root and all descendants
     * @param uri Document URI
     * @return Deletion result or null if not found
     */
    fun deleteRootAndDescendants(uri: String): DocumentDeletionResult?

    /**
     * Find document root by URI
     * @param uri Document URI
     * @return Content root or null if not found
     */
    fun findContentRootByUri(uri: String): ContentRoot?

    /**
     * Check if document with URI exists
     * @param uri Document URI
     * @return true if document exists
     */
    fun existsRootWithUri(uri: String): Boolean

    /**
     * Apply enhancers to a retrievable
     * @param retrievable Retrievable to enhance
     * @return Enhanced retrievable
     */
    fun <T : Retrievable> enhance(retrievable: T): T

    /**
     * Callback when new retrievables are created
     * @param retrievables List of new retrievables
     */
    fun onNewRetrievables(retrievables: List<Retrievable>)
}

Properties:

  • enhancers: List of enhancers to apply

Methods:

  • writeAndChunkDocument(): Parse, chunk, and store document
  • deleteRootAndDescendants(): Delete document and all chunks
  • findContentRootByUri(): Find document by URI
  • existsRootWithUri(): Check if document exists
  • enhance(): Apply all enhancers to retrievable
  • onNewRetrievables(): Hook for post-creation processing

Document Deletion

Results from document deletion operations.

DocumentDeletionResult

Information about deleted content.

data class DocumentDeletionResult(
    /**
     * URI of deleted document root
     */
    val rootUri: String,

    /**
     * Number of elements deleted
     */
    val deletedCount: Int
)

Properties:

  • rootUri: URI of deleted document
  • deletedCount: Total elements removed

Abstract Repository Implementation

Base class for implementing chunking repositories.

AbstractChunkingContentElementRepository

Abstract base class with core chunking logic.

abstract class AbstractChunkingContentElementRepository :
    ChunkingContentElementRepository {

    /**
     * Callback for newly created retrievables
     * Override to add custom behavior
     */
    override fun onNewRetrievables(retrievables: List<Retrievable>)

    /**
     * Persist chunks with their embeddings
     * Must be implemented by subclasses
     * @param chunks Chunks to persist
     * @param embeddings Map of chunk ID to embedding vector
     */
    protected abstract fun persistChunksWithEmbeddings(
        chunks: List<Chunk>,
        embeddings: Map<String, FloatArray>
    )

    /**
     * Create internal relationships between document elements
     * Must be implemented by subclasses
     * @param root Document root
     */
    protected abstract fun createInternalRelationships(root: NavigableDocument)

    /**
     * Commit changes to storage
     * Must be implemented by subclasses
     */
    protected abstract fun commit()

    /**
     * Final implementation of document writing with chunking
     * Handles embedding generation and calls protected methods
     * @param root Document to write
     * @return List of chunk IDs
     */
    final override fun writeAndChunkDocument(root: NavigableDocument): List<String>
}

Methods to Implement:

  • persistChunksWithEmbeddings(): Store chunks with embeddings
  • createInternalRelationships(): Build element relationships
  • commit(): Finalize transaction

Template Methods:

  • onNewRetrievables(): Hook for custom post-processing
  • writeAndChunkDocument(): Final implementation provided

Usage Examples

See the source documentation for comprehensive usage examples covering:

  • Basic repository operations (provision, save, find, info)
  • Working with chunking repository (writeAndChunkDocument, deletion)
  • Document lifecycle management
  • Using enhancers
  • Finding related chunks
  • Navigating hierarchies
  • Implementing custom repository
  • Repository information monitoring
  • Batch document ingestion
  • Updating documents
  • Repository health check
tessl i tessl/maven-com-embabel-agent--embabel-agent-rag-core@0.3.1

docs

index.md

README.md

tile.json