Table of Contents

Class TemplateContextBuilder

Namespace
Mythosia.AI.Rag
Assembly
Mythosia.AI.Rag.dll

IContextBuilder that uses a user-defined template with {context} and {question} placeholders.

public class TemplateContextBuilder : IContextBuilder
Inheritance
TemplateContextBuilder
Implements
Inherited Members

Constructors

TemplateContextBuilder(string)

Creates a template-based context builder.

public TemplateContextBuilder(string template)

Parameters

template string

Template string with placeholders: {context} โ€” replaced with numbered search results. {question} โ€” replaced with the user query.

Methods

BuildContext(string, IReadOnlyList<VectorSearchResult>)

Builds a context string from the user query and retrieved search results. The returned string is typically prepended to the LLM prompt as reference material.

public string BuildContext(string query, IReadOnlyList<VectorSearchResult> searchResults)

Parameters

query string

The original user query.

searchResults IReadOnlyList<VectorSearchResult>

The top-K search results from the vector store.

Returns

string

A formatted context string for the LLM.