Skip to content

prompt

prompt

Prompt assembly — system message + context + user question.

build_user_message

build_user_message(
    question: str, chunks: list[ChunkResult]
) -> str

Build the user message with RAG context for the LLM.

Formats retrieved chunks as a context block with source labels, followed by the user's question. Each chunk is prefixed with [Source: filename] and separated by horizontal rules.

Parameters:

Name Type Description Default
question str

The user's original question or prompt.

required
chunks list[ChunkResult]

List of ChunkResult objects from RAG retrieval, each containing text, source filename, and similarity score.

required

Returns:

Type Description
str

A formatted string with context block and question, ready

str

to be sent as a user message to the LLM.