aigc_prompt_composer 0.1.0-dev.2 copy "aigc_prompt_composer: ^0.1.0-dev.2" to clipboard
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));
}
1
likes
0
points
297
downloads

Publisher

unverified uploader

Weekly Downloads

A provider-neutral, extensible prompt composition toolkit for pure Dart applications.

Repository (GitHub)
View/report issues

Topics

#aigc #prompts #composition #localization #validation

License

unknown (license)

More

Packages that depend on aigc_prompt_composer