Skip to content
1 min read · 298 words

Variable: defaultRenderTransformersJsToolResult

ts
const defaultRenderTransformersJsToolResult: (input: {
  renderArtifactHandleBody?: (input: {
    artifact: unknown;
    byteLength: number;
    callId: string;
    encoding?: string;
    estimatedTokens?: number;
    lineCount: number;
  }) => string;
  renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string;
  renderUntrustedContent: (
    content: string,
    attrs: UntrustedContentAttrs,
  ) => string;
  results: Tokenizable | SpooledArtifact | Media | Media[] | SpooledArtifact[];
  tool: Tool<SpooledArtifact> | ArtifactTool | undefined;
  toolCall: ToolCall;
  unsupportedMediaPolicy: UnsupportedMediaPolicy;
  warn?: (msg: string) => void;
}) => Promise<string> = renderTransformersJsToolResult;

Defined in: src/batteries/llm/transformers_js/helpers.ts:275

Default renderTransformersJsToolResult.

Render a @nhtio/adk!ToolCall's results into a plain-text tool message body.

Parameters

ParameterTypeDescription
input{ renderArtifactHandleBody?: (input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => string; renderTrustedContent: (content: string, attrs: TrustedContentAttrs) => string; renderUntrustedContent: (content: string, attrs: UntrustedContentAttrs) => string; results: | Tokenizable | SpooledArtifact | Media | Media[] | SpooledArtifact[]; tool: | Tool<SpooledArtifact> | ArtifactTool | undefined; toolCall: ToolCall; unsupportedMediaPolicy: UnsupportedMediaPolicy; warn?: (msg: string) => void; }-
input.renderArtifactHandleBody?(input: { artifact: unknown; byteLength: number; callId: string; encoding?: string; estimatedTokens?: number; lineCount: number; }) => stringOverride for the artifact-handle body renderer (see renderArtifactHandleBody). Defaults to the shared defaultRenderArtifactHandleBody. The adapter threads the consumer's helpers.renderArtifactHandleBody here so an app can change which forged artifact_* reader the model is steered toward first.
input.renderTrustedContent(content: string, attrs: TrustedContentAttrs) => string-
input.renderUntrustedContent(content: string, attrs: UntrustedContentAttrs) => string-
input.results| Tokenizable | SpooledArtifact | Media | Media[] | SpooledArtifact[]-
input.tool| Tool<SpooledArtifact> | ArtifactTool | undefined-
input.toolCallToolCall-
input.unsupportedMediaPolicyUnsupportedMediaPolicy-
input.warn?(msg: string) => void-

Returns

Promise<string>

Remarks

transformers.js chat templates take a tool-role message whose content is a string. A SpooledArtifact result renders as a HANDLE (metadata + the forged artifact_* tools to read it) when its ToolCall.inline === false — the secure default — and inline via asString() only when a producer opted into inline: true. Applies the trust envelope and degrades Media to text.