TramAI - governed AI workflows for Java and Kotlin

tramai-rag

Version: 0.6.0
Status: Preview (published)
Role: Retrieval-Augmented Generation context pipeline.

Purpose

The tramai-rag module provides a comprehensive pipeline for injecting internal knowledge into LLM contexts. It handles document loading, text chunking, embedding generation, and vector retrieval.

Core Concepts

Document Pipeline

  • Loaders: Ingest external data into Document objects — FileDocumentLoader for files, UrlDocumentLoader for HTTP sources.
  • Chunkers: Break large documents into chunks — RecursiveCharacterChunker (overlapping, structure-aware), TokenAwareChunker, FixedSizeChunker.

Retrieval Pipeline

  • Embeddings: Interfaces with tramai-embedding to translate text chunks into high-dimensional vectors.
  • Vector Store Integration: Leverages tramai-vectorstore-spi to query databases like Chroma or Postgres pgvector for semantic similarity.
  • Context injection: RagPipeline.query(query, request, collection) retrieves the top matches and returns a ModelRequest enriched with them by ContextInjector.

Dependencies

// build.gradle.kts
dependencies {
    implementation(platform("dev.tramai:tramai-bom:0.6.0"))
    implementation("dev.tramai:tramai-rag")
    
    // RAG pipelines usually require embedding and a vector store
    implementation("dev.tramai:tramai-embedding")
    implementation("dev.tramai:tramai-vectorstore-chroma") // Or pgvector
}

When to use this module

  • You want the AI to answer questions based on your company's internal PDFs, documentation, or data.
  • You are building a "Chat with your data" feature.

When NOT to use this module

  • The AI only needs its base training knowledge to answer queries.
  • You are not executing semantic search.