AshAi.ChatUI.Tools (ash_ai v0.6.1)

Copy Markdown View Source

Normalizes tool call and tool result data for generated chat UIs.

mix ash_ai.gen.chat templates delegate to extract/1 so the generated modules stay small and the parsing behavior is centralized in AshAi.

Advanced apps can override the generated delegation seam:

@chat_ui_tools MyApp.ChatUITools

Summary

Types

extracted_tool_data()

@type extracted_tool_data() :: %{
  tool_calls: [tool_call()],
  tool_results: [tool_result()]
}

tool_call()

@type tool_call() :: %{
  id: String.t(),
  name: String.t(),
  arguments: map(),
  arguments_preview: String.t()
}

tool_result()

@type tool_result() :: %{
  id: String.t(),
  name: String.t() | nil,
  content: term(),
  is_error: boolean(),
  content_preview: String.t()
}

Functions

extract(message)

@spec extract(map() | struct()) ::
  {:ok, extracted_tool_data()} | {:error, Ash.Error.t()}