FencedCodeSelectionSource

Enums · AiDotNet.Enums

Records which fallback level produced the code returned by a fenced-code extraction.

For Beginners

When a chat model returns code it normally wraps it in triple backticks with a language name, like ````python. But models are inconsistent: sometimes the label is missing, sometimes it is wrong, and sometimes there are no backticks at all. The extractor tries each of those possibilities in turn, and this enum tells you which one actually worked. Treat [LanguageLabeledFence](/docs/reference/wiki/enums/fencedcodeselectionsource/) as trustworthy and [RawResponse`](/docs/reference/wiki/enums/fencedcodeselectionsource/) as a warning sign that the model did not follow the format.

How It Works

Extracting a full rewrite from a chat response walks a fixed ladder: a fence whose label matches the requested language, then any unlabelled fence, then any other labelled fence, then the raw response text. The reference implementation collapses that ladder into a single string and never says which rung it landed on, so a caller cannot tell a confident extraction from a desperate one. Reporting the rung makes the confidence explicit, so a pipeline can accept a labelled fence silently while asking for a retry when it had to fall back to raw prose.

Fields

Field Summary
FencedCodeSelectionSource LanguageLabeledFence A fence whose label matched the requested language, including its accepted aliases.
FencedCodeSelectionSource None No code could be recovered because the response was empty or whitespace only.
FencedCodeSelectionSource OtherLabeledFence A fence labelled with some other language, chosen only because nothing better existed.
FencedCodeSelectionSource RawResponse No fence at all; the whole response text was used verbatim.
FencedCodeSelectionSource UnlabeledFence A fence with no language label.
int value__