buildPrompt function

String buildPrompt({
  1. required String prompt,
  2. List<Context>? contexts,
})

Implementation

String buildPrompt({required String prompt, List<Context>? contexts}) {
  final sb = StringBuffer(prompt);
  if (contexts != null && contexts.isNotEmpty) {
    for (final context in contexts) {
      sb.writeln('\n');
      sb.writeln('=========== ${context.name == null ? '' : context.name!} CONTEXT ===========');
      sb.writeln(context.value);
      sb.writeln('=============================');
    }
  }
  return sb.toString();
}