Class CompressingQueryTransformer
java.lang.Object
dev.langchain4j.rag.query.transformer.CompressingQueryTransformer
- All Implemented Interfaces:
QueryTransformer
A
Configurable parameters (optional):
-
QueryTransformer
that leverages a ChatLanguageModel
to condense a given Query
along with a chat memory (previous conversation history) into a concise Query
.
This is applicable only when a ChatMemory
is in use.
Refer to DEFAULT_PROMPT_TEMPLATE
and implementation for more details.
Configurable parameters (optional):
-
promptTemplate
: The prompt template used to instruct the LLM to compress the specified Query
.- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ChatLanguageModel
static final PromptTemplate
protected final PromptTemplate
-
Constructor Summary
ConstructorDescriptionCompressingQueryTransformer
(ChatLanguageModel chatLanguageModel) CompressingQueryTransformer
(ChatLanguageModel chatLanguageModel, PromptTemplate promptTemplate) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
protected Prompt
createPrompt
(Query query, String chatMemory) protected String
format
(ChatMessage message) protected String
format
(List<ChatMessage> chatMemory)
-
Field Details
-
DEFAULT_PROMPT_TEMPLATE
-
promptTemplate
-
chatLanguageModel
-
-
Constructor Details
-
CompressingQueryTransformer
-
CompressingQueryTransformer
public CompressingQueryTransformer(ChatLanguageModel chatLanguageModel, PromptTemplate promptTemplate)
-
-
Method Details
-
builder
-
transform
Description copied from interface:QueryTransformer
- Specified by:
transform
in interfaceQueryTransformer
- Parameters:
query
- TheQuery
to be transformed.- Returns:
- A collection of one or more
Query
s derived from the originalQuery
.
-
format
-
format
-
createPrompt
-