RAGConfig

org.llm4s.rag.RAGConfig
See theRAGConfig companion object
final case class RAGConfig(embeddingProvider: EmbeddingProvider, embeddingModel: Option[String], embeddingDimensions: Option[Int], chunkingStrategy: Strategy, chunkingConfig: ChunkingConfig, fusionStrategy: FusionStrategy, topK: Int, rerankingStrategy: RerankingStrategy, rerankTopK: Int, vectorStorePath: Option[String], keywordIndexPath: Option[String], pgVectorConnectionString: Option[String], pgVectorUser: Option[String], pgVectorPassword: Option[String], pgVectorTableName: Option[String], llmClient: Option[LLMClient], systemPrompt: Option[String], tracer: Option[Tracing], documentLoaders: Seq[DocumentLoader], loadingConfig: LoadingConfig)

Configuration for RAG pipeline.

Uses immutable copy pattern for fluent configuration. All settings have sensible defaults for quick start.

Attributes

Example
// Minimal configuration
val config = RAGConfig()
 .withEmbeddings(EmbeddingProvider.OpenAI)
// Full customization with SQLite
val config = RAGConfig()
 .withEmbeddings(EmbeddingProvider.OpenAI, "text-embedding-3-large")
 .withChunking(ChunkerFactory.Strategy.Sentence, 800, 150)
 .withRRF(60)
 .withSQLite("./rag.db")
 .withLLM(llmClient)
// Using PostgreSQL with pgvector
val config = RAGConfig()
 .withEmbeddings(EmbeddingProvider.OpenAI)
 .withPgVector("jdbc:postgresql://localhost:5432/mydb", "user", "pass", "embeddings")
Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def failOnLoadError(fail: Boolean): RAGConfig

Set whether to stop on first loading error.

Set whether to stop on first loading error.

Attributes

Use in-memory storage (default)

Use in-memory storage (default)

Attributes

Use keyword search only (no vector)

Use keyword search only (no vector)

Attributes

Use vector search only (no keyword)

Use vector search only (no keyword)

Attributes

def withBatchSize(n: Int): RAGConfig

Set batch size for embedding operations.

Set batch size for embedding operations.

Attributes

def withChunking(strategy: Strategy): RAGConfig

Configure chunking strategy

Configure chunking strategy

Attributes

def withChunking(strategy: Strategy, config: ChunkingConfig): RAGConfig

Configure chunking strategy with custom config

Configure chunking strategy with custom config

Attributes

def withChunking(strategy: Strategy, size: Int, overlap: Int): RAGConfig

Configure chunking with size and overlap

Configure chunking with size and overlap

Attributes

def withCohereReranking(model: String): RAGConfig

Use Cohere cross-encoder reranking

Use Cohere cross-encoder reranking

Attributes

Add a document loader for build-time ingestion.

Add a document loader for build-time ingestion.

Documents will be ingested when RAG.build() is called.

Attributes

def withDocuments(path: String): RAGConfig

Add documents from a directory path.

Add documents from a directory path.

Attributes

def withDocuments(loaders: Seq[DocumentLoader]): RAGConfig

Add multiple document loaders.

Add multiple document loaders.

Attributes

Override embedding dimensions (auto-detected by default)

Override embedding dimensions (auto-detected by default)

Attributes

Configure embedding provider

Configure embedding provider

Attributes

def withEmbeddings(provider: EmbeddingProvider, model: String): RAGConfig

Configure embedding provider and model

Configure embedding provider and model

Attributes

def withEmbeddings(provider: EmbeddingProvider, model: String, dimensions: Int): RAGConfig

Configure embedding provider, model, and dimensions

Configure embedding provider, model, and dimensions

Attributes

Configure fusion strategy

Configure fusion strategy

Attributes

def withLLM(client: LLMClient): RAGConfig

Configure LLM client for answer generation

Configure LLM client for answer generation

Attributes

Use LLM-based reranking

Use LLM-based reranking

Attributes

Configure document loading behavior.

Configure document loading behavior.

Attributes

def withParallelism(n: Int): RAGConfig

Set parallelism for document processing.

Set parallelism for document processing.

Attributes

Use PostgreSQL with pgvector extension for vector storage.

Use PostgreSQL with pgvector extension for vector storage.

Connects to localhost:5432/postgres with user "postgres" by default. Uses "vectors" as the default table name.

Attributes

def withPgVector(tableName: String): RAGConfig

Use PostgreSQL with pgvector extension for vector storage.

Use PostgreSQL with pgvector extension for vector storage.

Connects to localhost:5432/postgres with user "postgres" by default.

Value parameters

tableName

Table name for vectors

Attributes

def withPgVector(connectionString: String, user: String, password: String, tableName: String): RAGConfig

Use PostgreSQL with pgvector extension for vector storage.

Use PostgreSQL with pgvector extension for vector storage.

Value parameters

connectionString

JDBC connection string (e.g., "jdbc:postgresql://host:port/database")

password

Database password

tableName

Table name for vectors

user

Database user

Attributes

def withRRF(k: Int): RAGConfig

Use RRF fusion with custom k parameter

Use RRF fusion with custom k parameter

Attributes

def withRerankTopK(k: Int): RAGConfig

Configure number of candidates to rerank

Configure number of candidates to rerank

Attributes

Configure reranking strategy

Configure reranking strategy

Attributes

def withSQLite(dbPath: String): RAGConfig

Use SQLite for persistent storage

Use SQLite for persistent storage

Attributes

def withSystemPrompt(prompt: String): RAGConfig

Configure system prompt for answer generation

Configure system prompt for answer generation

Attributes

def withTopK(k: Int): RAGConfig

Configure number of results to return

Configure number of results to return

Attributes

def withTracing(tracer: Tracing): RAGConfig

Enable tracing for cost tracking and observability

Enable tracing for cost tracking and observability

Attributes

def withWeightedScore(vectorWeight: Double, keywordWeight: Double): RAGConfig

Use weighted score fusion

Use weighted score fusion

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product