UserPromptAugmenter

class UserPromptAugmenter(template: String = DEFAULT_USER_PROMPT_TEMPLATE, contextPrefix: String = PromptAugmenter.DEFAULT_CONTEXT_PREFIX) : PromptAugmenter(source)

A PromptAugmenter that injects retrieved context into the last Message.User of the prompt.

The retrieved context is rendered through template and added as an additional MessagePart.Text appended to the existing parts of the last user message. The original user message is replaced with a copy that:

If the prompt contains no Message.User, or the formatted context is blank, or the relevant context list is empty, the original prompt is returned unchanged.

Parameters

template

The template for user context insertion. Use PromptAugmenter.RELEVANT_CONTEXT_PLACEHOLDER placeholder.

contextPrefix

The prefix to add before relevant context.

See also

Constructors

Link copied to clipboard
constructor(template: String = DEFAULT_USER_PROMPT_TEMPLATE, contextPrefix: String = PromptAugmenter.DEFAULT_CONTEXT_PREFIX)

Types

Link copied to clipboard
class Builder

Builder for UserPromptAugmenter.

Link copied to clipboard
object Companion

Companion object with default templates.

Functions

Link copied to clipboard
open override fun augment(originalPrompt: Prompt, relevantContext: List<SearchResult<TextDocument>>): Prompt

Augments the given prompt with relevant context.