Jido.AI.Reasoning.TreeOfThoughts.Result (Jido AI v2.2.0)

Copy Markdown View Source

Canonical structured result contract for Tree-of-Thoughts executions.

This module builds a stable result payload from machine state that is safe for SDK consumers and CLI projections.

Summary

Functions

Extracts the best answer string from a structured ToT result.

Builds a structured ToT result from machine state.

Returns ranked candidates from a structured ToT result.

Types

candidate()

@type candidate() :: %{
  node_id: String.t(),
  content: String.t(),
  score: float() | nil,
  depth: non_neg_integer(),
  path_ids: [String.t()],
  path_text: [String.t()]
}

t()

@type t() :: %{
  best: candidate() | nil,
  candidates: [candidate()],
  termination: termination(),
  tree: tree(),
  usage: map(),
  diagnostics: map()
}

termination()

@type termination() :: %{
  reason: atom() | nil,
  status:
    Jido.AI.Reasoning.TreeOfThoughts.Machine.external_status()
    | String.t()
    | nil,
  depth_reached: non_neg_integer(),
  node_count: non_neg_integer(),
  duration_ms: non_neg_integer()
}

tree()

@type tree() :: %{
  node_count: non_neg_integer(),
  frontier_size: non_neg_integer(),
  traversal_strategy:
    Jido.AI.Reasoning.TreeOfThoughts.Machine.traversal_strategy() | atom(),
  max_depth: pos_integer(),
  branching_factor: pos_integer()
}

Functions

best_answer(arg1)

@spec best_answer(map() | nil) :: String.t() | nil

Extracts the best answer string from a structured ToT result.

build(machine, opts \\ [])

Builds a structured ToT result from machine state.

top_candidates(arg1, limit)

@spec top_candidates(map() | nil, pos_integer()) :: [candidate()]

Returns ranked candidates from a structured ToT result.