org.llm4s.rag.transform

Members list

Type members

Classlikes

Pass-through transformer that returns the query unchanged.

Pass-through transformer that returns the query unchanged.

Useful for:

  • Testing pipeline composition without side effects
  • Default/placeholder when no transformation is needed
  • Verifying that the transform chain is invoked correctly

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
final class LLMQueryRewriter(llmClient: LLMClient, systemPrompt: String) extends QueryTransformer

Rewrites user queries using an LLM to improve retrieval quality.

Rewrites user queries using an LLM to improve retrieval quality.

Takes vague, conversational, or poorly-formed queries and rewrites them into precise search queries optimized for semantic vector search.

Value parameters

llmClient

The LLM client to use for rewriting

systemPrompt

Custom system prompt (uses default if not provided)

Attributes

Example
val rewriter = LLMQueryRewriter(llmClient)
rewriter.transform("tell me about that config thing")
// Right("RAGConfig configuration options builder pattern settings")
rewriter.transform("how do I use it with postgres?")
// Right("PostgreSQL pgvector integration RAG pipeline configuration")
Companion
object
Supertypes
class Object
trait Matchable
class Any

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type

Composable pre-retrieval query transformation.

Composable pre-retrieval query transformation.

QueryTransformers modify user queries before they are embedded and sent to the vector store, improving retrieval quality.

Transforms are applied sequentially in the order they are added to RAGConfig. Each transform receives the output of the previous one.

Attributes

Example
val rag = RAG.builder()
 .withEmbeddings(EmbeddingProvider.OpenAI)
 .withQueryTransformer(LLMQueryRewriter(llmClient))
 .build()
// "tell me about that config thing"
// → rewritten to "RAGConfig configuration options and builder pattern"
// → then embedded and searched
val results = rag.query("tell me about that config thing")
Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type