View Source LangChain.Message.ToolCall (LangChain v0.3.0-rc.0)

Represents an LLM's request to use tool. It specifies the tool to execute and may provide arguments for the tool to use.

Example

ToolCall.new!(%{
  call_id: "call_123",
  name: "give_greeting"
  arguments: %{"name" => "Howard"}
})

Summary

Functions

Ensure the ToolCall's status is set to :complete. The process of completing it parses the tool arguments, which may be invalid. Any problems parsing are returned as a changeset error.

The left side, or primary, is the ToolCall that is being accumulated. The call_part is being merged into the primary.

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

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

Types

@type t() :: %LangChain.Message.ToolCall{
  arguments: term(),
  call_id: term(),
  index: term(),
  name: term(),
  status: term(),
  type: term()
}

Functions

@spec complete(t()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Ensure the ToolCall's status is set to :complete. The process of completing it parses the tool arguments, which may be invalid. Any problems parsing are returned as a changeset error.

Link to this function

merge(primary, call_part)

View Source
@spec merge(nil | t(), t()) :: t()

The left side, or primary, is the ToolCall that is being accumulated. The call_part is being merged into the primary.

Used to process streamed deltas where a single tool call can be split over many smaller parts.

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

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

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

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