Class DefaultContentInjector
java.lang.Object
dev.langchain4j.rag.content.injector.DefaultContentInjector
- All Implemented Interfaces:
ContentInjector
Default implementation of
It's important to note that while efforts will be made to avoid breaking changes, the default behavior of this class may be updated in the future if it's found that the current behavior does not adequately serve the majority of use cases. Such changes would be made to benefit both current and future users.
This implementation appends all given
Configurable parameters (optional):
-
-
ContentInjector
intended to be suitable for the majority of use cases.
It's important to note that while efforts will be made to avoid breaking changes, the default behavior of this class may be updated in the future if it's found that the current behavior does not adequately serve the majority of use cases. Such changes would be made to benefit both current and future users.
This implementation appends all given
Content
s to the end of the given UserMessage
in their order of iteration.
Refer to DEFAULT_PROMPT_TEMPLATE
and implementation for more details.
Configurable parameters (optional):
-
promptTemplate
: The prompt template that defines how the original userMessage
and contents
are combined into the resulting UserMessage
.
The text of the template should contain the {{userMessage}}
and {{contents}}
variables.
-
metadataKeysToInclude
: A list of Metadata
keys that should be included
with each Content.textSegment()
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultContentInjector
(PromptTemplate promptTemplate) DefaultContentInjector
(PromptTemplate promptTemplate, List<String> metadataKeysToInclude) DefaultContentInjector
(List<String> metadataKeysToInclude) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
protected Prompt
createPrompt
(ChatMessage chatMessage, List<Content> contents) protected String
protected String
protected String
protected String
inject
(List<Content> contents, ChatMessage chatMessage) Injects givenContent
s into a givenChatMessage
.
-
Field Details
-
DEFAULT_PROMPT_TEMPLATE
-
-
Constructor Details
-
DefaultContentInjector
public DefaultContentInjector() -
DefaultContentInjector
-
DefaultContentInjector
-
DefaultContentInjector
-
-
Method Details
-
builder
-
inject
Description copied from interface:ContentInjector
Injects givenContent
s into a givenChatMessage
.- Specified by:
inject
in interfaceContentInjector
- Parameters:
contents
- The list ofContent
to be injected.chatMessage
- TheChatMessage
into which theContent
s are to be injected. Currently, onlyUserMessage
is supported.- Returns:
- The
ChatMessage
with the injectedContent
s.
-
createPrompt
-
format
-
format
-
format
-
format
-