Class OutputFormatter
- Namespace
- JD.AI.Core.Infrastructure
- Assembly
- JD.AI.Core.dll
Centralized output formatting for tool responses. Provides consistent error messages, code blocks, truncation, and markdown formatting.
public static class OutputFormatter
- Inheritance
-
OutputFormatter
- Inherited Members
Fields
DefaultMaxLength
Default maximum output length before truncation.
public const int DefaultMaxLength = 100000
Field Value
Methods
BulletList(IEnumerable<string>)
Formats a bullet list from items.
public static string BulletList(IEnumerable<string> items)
Parameters
itemsIEnumerable<string>
Returns
CodeBlock(string, string?)
Formats content as a fenced code block.
public static string CodeBlock(string content, string? language = null)
Parameters
Returns
Error(string)
Formats a standard error message.
public static string Error(string message)
Parameters
messagestring
Returns
Error(string, Exception)
Formats an error from an exception.
public static string Error(string context, Exception ex)
Parameters
Returns
Error(string, string)
Formats an error with a context prefix.
public static string Error(string context, string details)
Parameters
Returns
FromProcessResult(ProcessResult, string?)
Formats a process result into a tool-friendly string.
public static string FromProcessResult(ProcessResult result, string? context = null)
Parameters
resultProcessResultcontextstring
Returns
Info(string)
Formats an informational message.
public static string Info(string message)
Parameters
messagestring
Returns
JsonBlock(string)
Formats content as a JSON code block.
public static string JsonBlock(string json)
Parameters
jsonstring
Returns
MarkdownTable(IEnumerable<(string Key, string Value)>)
Formats a markdown table from rows of key-value data.
public static string MarkdownTable(IEnumerable<(string Key, string Value)> rows)
Parameters
rowsIEnumerable<(string Key, string Value)>
Returns
MarkdownTable(string[], IEnumerable<string[]>)
Formats a markdown table with custom headers and row data.
public static string MarkdownTable(string[] headers, IEnumerable<string[]> rows)
Parameters
headersstring[]rowsIEnumerable<string[]>
Returns
Success(string)
Formats a success message with an emoji prefix.
public static string Success(string message)
Parameters
messagestring
Returns
Truncate(string, int)
Truncates text to a maximum length, appending a truncation notice.
public static string Truncate(string text, int maxLength = 100000)
Parameters
Returns
Warning(string)
Formats a warning message with an emoji prefix.
public static string Warning(string message)
Parameters
messagestring