promptFragment static method
Compact prompt text describing the output format, generated from
vocabulary (for models without schema-constrained output). With
steerableOnly, families offers only steerableFamilies.
Implementation
static String promptFragment({bool steerableOnly = true}) {
final b = StringBuffer()
..writeln(
'Reply with one JSON object describing a calculator theme that '
'matches the words. Every field is optional: leave out what the '
'words do not suggest. Use only these values.',
);
for (final f in vocabulary) {
final values = [
for (final v in f.values)
if (!steerableOnly || v.steerable) v,
];
switch (f.kind) {
case IntentFieldKind.oneOf:
b.writeln('- ${f.name} (${f.description}): one of');
case IntentFieldKind.listOf:
b.writeln(
'- ${f.name} (${f.description}): up to ${f.maxItems} of',
);
case IntentFieldKind.text:
b.writeln(
'- ${f.name}: ${f.description}, at most ${f.maxWords} words',
);
}
for (final v in values) {
b.writeln(' ${v.value}: ${v.description}');
}
}
b.write(
'Example for "playful greenery": '
'${jsonEncode({
'brightness': 'light',
'colors': ['green', 'lime'],
'chroma': 'vivid',
'harmony': 'analogous',
'name': 'Playful Greenery',
})}',
);
return b.toString();
}