View Source LangChain.Message.ToolResult (LangChain v0.3.3)

Represents a the result of running a requested tool. The LLM's requests a tool use through a ToolCall. A ToolResult returns the answer or result from the application back to the AI.

Content

The content is a string that gets returned to the LLM as the result.

Processed Content

The processed_content field is optional. When you want to keep the results of the Elixir function call as a native Elixir data structure, processed_content can hold it.

To do this, the Elixir function's result should be a {:ok, "String response for LLM", native_elixir_data}. See LangChain.Function for details and examples.

Summary

Functions

Build a new ToolResult and return an :ok/:error tuple with the result.

Build a new ToolResult and return it or raise an error if invalid.

Types

@type t() :: %LangChain.Message.ToolResult{
  content: term(),
  display_text: term(),
  is_error: term(),
  name: term(),
  options: term(),
  processed_content: term(),
  tool_call_id: term(),
  type: term()
}

Functions

@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Build a new ToolResult and return an :ok/:error tuple with the result.

@spec new!(attrs :: map()) :: t() | no_return()

Build a new ToolResult and return it or raise an error if invalid.