ProgramPromptTemplateSet

Models & Types · AiDotNet.Evolution.Prompts

The complete, validated collection of prompt texts and phrases a program-evolution run renders.

For Beginners

This is the wording your AI-driven search uses, all in one place. You get a complete, working set for free by calling CreateDefault. To change any part of it, either call With with your own text or drop a .txt file into a folder and call LoadFromDirectory — file diff_user.txt replaces the diff request, system_message.txt replaces the standing instructions, and so on. Whatever you supply is checked straight away, so a typo in a fill-in-the-blank name is reported while you are setting up rather than after the run has been going for an hour.

How It Works

A set holds one ProgramPromptTemplate for every ProgramPromptTemplateKey and one short phrase for every ProgramPromptFragmentKey. It is immutable: With and WithFragment return a new set, and LoadFromDirectory layers files from a directory over the shipped defaults. Every construction path validates, so an invalid set cannot exist — a template that drops a structurally required slot, or a phrase that asks for an argument it will never be given, is refused at the point it is configured rather than at the point a model is first called.

Defaults are compiled into the assembly rather than read from files beside it, so they can never be missing, truncated, or shadowed by a stale copy on disk. Overrides are read as UTF-8 by file stem, which is the same layout the reference OpenEvolve implementation uses, so an existing template directory transfers unchanged — but read correctly: upstream opens template files in the platform’s default encoding, which turns every non-ASCII character in a UTF-8 template into mojibake on a Windows machine. Upstream also carries a set of in-module default templates that nothing ever reads and that have drifted out of step with the files that are actually loaded; there is one source of truth here.

VersionHash covers every template and phrase, so folding it into an operator’s version identity makes an edited prompt visible to checkpoint resume: a run cannot silently continue with different wording than it started with.

Properties

Property Summary
IReadOnlyList<ProgramPromptFragmentKey> FragmentKeys { get; } Gets every phrase key this set resolves, in a stable order.
IReadOnlyList<ProgramPromptTemplateKey> TemplateKeys { get; } Gets every template key this set resolves, in a stable order.
string VersionHash { get; } Gets a hash over every template and phrase in this set.

Methods

Method Summary
IReadOnlyList<string> DeclaredFragmentArguments(ProgramPromptFragmentKey key) Gets the argument names a phrase is allowed to use.
IReadOnlyList<string> RequiredPlaceholders(ProgramPromptTemplateKey key) Gets the placeholders a template must keep to remain structurally usable.
IReadOnlyList<string> SuppliedPlaceholders(ProgramPromptTemplateKey key) Gets the placeholder names the prompt builder supplies to a template.
ProgramPromptTemplate GetFragment(ProgramPromptFragmentKey key) Gets the phrase registered for a key.
ProgramPromptTemplate GetTemplate(ProgramPromptTemplateKey key) Gets the template registered for a key.
ProgramPromptTemplateSet CreateDefault() Creates the set of texts and phrases that ship with the library.
ProgramPromptTemplateSet LoadFromDirectory(string directory) Loads a directory of overrides over the shipped defaults.
ProgramPromptTemplateSet LoadFromDirectory(string directory, ProgramPromptTemplateSet baseSet) Loads a directory of overrides over an existing set.
ProgramPromptTemplateSet With(ProgramPromptTemplateKey key, string text) Returns a copy of this set with one template replaced.
ProgramPromptTemplateSet WithFragment(ProgramPromptFragmentKey key, string text) Returns a copy of this set with one phrase replaced.
string FragmentName(ProgramPromptFragmentKey key) Gets the name a phrase override is read under inside the fragments file.
string RenderFragment(ProgramPromptFragmentKey key) Renders a phrase that takes no arguments.
string RenderFragment(ProgramPromptFragmentKey key, IReadOnlyDictionary<string, string> values) Renders a phrase with the arguments it declares.
string TemplateFileStem(ProgramPromptTemplateKey key) Gets the file stem an override for a template key is read from.
string ToString() Returns a short description that never echoes template text.

Fields

Field Summary
int MaxFragmentLength The largest phrase text accepted, in characters.
string FragmentsFileName The file name, inside a template directory, that carries phrase overrides.