QueryTransformer

org.llm4s.rag.transform.QueryTransformer
See theQueryTransformer companion object

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
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def name: String

Human-readable name for this transformer (used in logging/tracing).

Human-readable name for this transformer (used in logging/tracing).

Attributes

def transform(query: String): Result[String]

Transform a query before embedding and retrieval.

Transform a query before embedding and retrieval.

Value parameters

query

The original or previously-transformed query

Attributes

Returns

The transformed query, or an error