format method
Format for display.
Implementation
String format() {
final buf = StringBuffer()
..writeln('Web search results for query: "$query"\n');
for (final result in results) {
if (result is String) {
buf.writeln(result);
} else if (result is SearchResult) {
buf.writeln('- [${result.title}](${result.url})');
if (result.snippet != null) {
buf.writeln(' ${result.snippet}');
}
} else if (result is List<SearchResult>) {
for (final r in result) {
buf.writeln('- [${r.title}](${r.url})');
}
}
}
buf.writeln();
buf.writeln(
'REMINDER: You MUST include the sources above in your response '
'to the user using markdown hyperlinks.',
);
return buf.toString();
}