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
Contents 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 PromptcreatePrompt(ChatMessage chatMessage, List<Content> contents) protected Stringprotected Stringprotected Stringprotected Stringinject(List<Content> contents, ChatMessage chatMessage) Injects givenContents into a givenChatMessage.
-
Field Details
-
DEFAULT_PROMPT_TEMPLATE
-
-
Constructor Details
-
DefaultContentInjector
public DefaultContentInjector() -
DefaultContentInjector
-
DefaultContentInjector
-
DefaultContentInjector
-
-
Method Details
-
builder
-
inject
Description copied from interface:ContentInjectorInjects givenContents into a givenChatMessage.- Specified by:
injectin interfaceContentInjector- Parameters:
contents- The list ofContentto be injected.chatMessage- TheChatMessageinto which theContents are to be injected. Currently, onlyUserMessageis supported.- Returns:
- The
ChatMessagewith the injectedContents.
-
createPrompt
-
format
-
format
-
format
-
format
-