Class CompressingQueryTransformer
java.lang.Object
dev.langchain4j.rag.query.transformer.CompressingQueryTransformer
- All Implemented Interfaces:
QueryTransformer
A
Configurable parameters (optional):
-
QueryTransformer that leverages a ChatModel 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
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ChatModelstatic final PromptTemplateprotected final PromptTemplate -
Constructor Summary
ConstructorsConstructorDescriptionCompressingQueryTransformer(ChatModel chatModel) CompressingQueryTransformer(ChatModel chatModel, PromptTemplate promptTemplate) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()protected PromptcreatePrompt(Query query, String chatMemory) protected Stringformat(ChatMessage message) protected Stringformat(List<ChatMessage> chatMemory)
-
Field Details
-
DEFAULT_PROMPT_TEMPLATE
-
promptTemplate
-
chatModel
-
-
Constructor Details
-
CompressingQueryTransformer
-
CompressingQueryTransformer
-
-
Method Details
-
builder
-
transform
Description copied from interface:QueryTransformer- Specified by:
transformin interfaceQueryTransformer- Parameters:
query- TheQueryto be transformed.- Returns:
- A collection of one or more
Querys derived from the originalQuery.
-
format
-
format
-
createPrompt
-