Pi.Protocol.Tool.OutputPart (pi_bridge v0.6.22)

Copy Markdown View Source

Semantic output part for tool renderers.

Summary

Functions

Decodes a JSON string into this struct.

Decodes a JSON string into this struct, raising on failure.

Dumps this struct into JSON-shaped data, respecting JSON field names.

Builds this struct from a decoded JSON map.

Builds this struct from a decoded JSON map, raising on failure.

Returns a JSON Schema-compatible schema map.

Returns a JSON Schema-compatible schema map.

Converts this struct into a JSON-shaped map.

Types

kind()

@type kind() ::
  :text
  | :inspect
  | :markdown
  | :code
  | :error
  | :diff
  | :table
  | :tree
  | :document

t()

@type t() :: %Pi.Protocol.Tool.OutputPart{
  body: String.t(),
  data: map(),
  kind: kind(),
  language: String.t() | nil,
  title: String.t() | nil,
  truncation: truncation()
}

truncation()

@type truncation() :: :head | :tail | nil

Functions

code(body, opts \\ [])

@spec code(
  String.t(),
  keyword()
) :: t()

decode(json)

Decodes a JSON string into this struct.

decode!(json)

Decodes a JSON string into this struct, raising on failure.

diff(body, opts \\ [])

@spec diff(
  String.t(),
  keyword()
) :: t()

document(body, opts \\ [])

@spec document(
  String.t(),
  keyword()
) :: t()

dump(struct)

Dumps this struct into JSON-shaped data, respecting JSON field names.

error(body, opts \\ [])

@spec error(
  String.t(),
  keyword()
) :: t()

from_map(map)

Builds this struct from a decoded JSON map.

from_map!(map)

Builds this struct from a decoded JSON map, raising on failure.

inspect(body, opts \\ [])

@spec inspect(
  String.t(),
  keyword()
) :: t()

json_schema()

Returns a JSON Schema-compatible schema map.

markdown(body, opts \\ [])

@spec markdown(
  String.t(),
  keyword()
) :: t()

schema()

Returns a JSON Schema-compatible schema map.

table(body, opts \\ [])

@spec table(
  String.t(),
  keyword()
) :: t()

text(body, opts \\ [])

@spec text(
  String.t(),
  keyword()
) :: t()

to_map(struct)

Converts this struct into a JSON-shaped map.

tree(body, opts \\ [])

@spec tree(
  String.t(),
  keyword()
) :: t()