Class RewriteQueryTransformer
java.lang.Object
org.springframework.ai.rag.preretrieval.query.transformation.RewriteQueryTransformer
- All Implemented Interfaces:
Function<Query,,Query> QueryTransformer
Uses a large language model to rewrite a user query to provide better results when
querying a target system, such as a vector store or a web search engine.
This transformer is useful when the user query is verbose, ambiguous, or contains irrelevant information that may affect the quality of the search results.
- Since:
- 1.0.0
- Author:
- Thomas Vitale
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRewriteQueryTransformer(org.springframework.ai.chat.client.ChatClient.Builder chatClientBuilder, org.springframework.ai.chat.prompt.PromptTemplate promptTemplate, String targetSearchSystem) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()Transforms the given query according to the implemented strategy.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.rag.preretrieval.query.transformation.QueryTransformer
apply
-
Constructor Details
-
RewriteQueryTransformer
public RewriteQueryTransformer(org.springframework.ai.chat.client.ChatClient.Builder chatClientBuilder, @Nullable org.springframework.ai.chat.prompt.PromptTemplate promptTemplate, @Nullable String targetSearchSystem)
-
-
Method Details
-
transform
Description copied from interface:QueryTransformerTransforms the given query according to the implemented strategy.- Specified by:
transformin interfaceQueryTransformer- Parameters:
query- The original query to transform- Returns:
- The transformed query
-
builder
-