class ToolChoice

Controls whether and which tool a model must call, mapped to each provider's native tool_choice field.

Constants

auto

none

required

tool

Methods

__construct(string $mode, string|null $toolName = null)

Create a tool choice.

static ToolChoice
tool(string $name)

Require the model to call the tool with the given name.

static ToolChoice
from(ToolChoice|string|array $value)

Coerce a ToolChoice, a mode string, or a ['tool' => 'name'] array into a ToolChoice instance.

Details

at line 29
__construct(string $mode, string|null $toolName = null)

Create a tool choice.

Parameters

string $mode
string|null $toolName

at line 49
static ToolChoice tool(string $name)

Require the model to call the tool with the given name.

Parameters

string $name

Return Value

ToolChoice

at line 59
static ToolChoice from(ToolChoice|string|array $value)

Coerce a ToolChoice, a mode string, or a ['tool' => 'name'] array into a ToolChoice instance.

Parameters

ToolChoice|string|array $value

Return Value

ToolChoice