Table of Contents

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

int

Methods

BulletList(IEnumerable<string>)

Formats a bullet list from items.

public static string BulletList(IEnumerable<string> items)

Parameters

items IEnumerable<string>

Returns

string

CodeBlock(string, string?)

Formats content as a fenced code block.

public static string CodeBlock(string content, string? language = null)

Parameters

content string
language string

Returns

string

Error(string)

Formats a standard error message.

public static string Error(string message)

Parameters

message string

Returns

string

Error(string, Exception)

Formats an error from an exception.

public static string Error(string context, Exception ex)

Parameters

context string
ex Exception

Returns

string

Error(string, string)

Formats an error with a context prefix.

public static string Error(string context, string details)

Parameters

context string
details string

Returns

string

FromProcessResult(ProcessResult, string?)

Formats a process result into a tool-friendly string.

public static string FromProcessResult(ProcessResult result, string? context = null)

Parameters

result ProcessResult
context string

Returns

string

Info(string)

Formats an informational message.

public static string Info(string message)

Parameters

message string

Returns

string

JsonBlock(string)

Formats content as a JSON code block.

public static string JsonBlock(string json)

Parameters

json string

Returns

string

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

rows IEnumerable<(string Key, string Value)>

Returns

string

MarkdownTable(string[], IEnumerable<string[]>)

Formats a markdown table with custom headers and row data.

public static string MarkdownTable(string[] headers, IEnumerable<string[]> rows)

Parameters

headers string[]
rows IEnumerable<string[]>

Returns

string

Success(string)

Formats a success message with an emoji prefix.

public static string Success(string message)

Parameters

message string

Returns

string

Truncate(string, int)

Truncates text to a maximum length, appending a truncation notice.

public static string Truncate(string text, int maxLength = 100000)

Parameters

text string
maxLength int

Returns

string

Warning(string)

Formats a warning message with an emoji prefix.

public static string Warning(string message)

Parameters

message string

Returns

string