aigc_prompt_composer 0.1.0-dev.2
aigc_prompt_composer: ^0.1.0-dev.2 copied to clipboard
A provider-neutral, extensible prompt composition toolkit for pure Dart applications.
example/main.dart
import 'package:aigc_prompt_composer/aigc_prompt_composer.dart';
/// Runs the primary package example shown by pub.dev.
void main() {
final schema = PromptSchema(
id: 'public-example.v1',
version: '1',
defaultLocale: 'en',
sections: <PromptSectionDefinition>[
PromptSectionDefinition(
id: 'subject',
order: 10,
required: true,
localizedHeaders: const <String, String>{'en': 'Subject'},
),
PromptSectionDefinition(
id: 'style',
order: 20,
localizedHeaders: const <String, String>{'en': 'Style'},
),
],
);
final result = PromptComposer().compose(
schema: schema,
recipe: PromptRecipe(
schemaId: schema.id,
variables: const <String, Object?>{'material': 'polished stone'},
fragments: <PromptFragment>[
PromptFragment.text(
id: 'subject-sculpture',
sectionId: 'subject',
content: 'A {{material}} sculpture beside a calm lake',
),
PromptFragment.text(
id: 'style-natural',
sectionId: 'style',
content: 'Natural color, balanced composition, fine detail',
),
],
),
);
if (!result.isValid) {
throw StateError('The example prompt must be valid.');
}
print(const PlainTextPromptRenderer().render(result));
}