SystemPromptAugmenter

class SystemPromptAugmenter(template: String = DEFAULT_SYSTEM_PROMPT_TEMPLATE, contextPrefix: String = PromptAugmenter.DEFAULT_CONTEXT_PREFIX) : PromptAugmenter(source)

A PromptAugmenter that injects retrieved context into the first Message.System of the prompt.

The retrieved context is rendered through template and added as an additional MessagePart.Text appended to the existing parts of the first system message, separated by PromptAugmenter.SECTION_SEPARATOR. The original system message is replaced with a copy that:

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

Parameters

template

The template for the system message. 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_SYSTEM_PROMPT_TEMPLATE, contextPrefix: String = PromptAugmenter.DEFAULT_CONTEXT_PREFIX)

Types

Link copied to clipboard
class Builder
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.