Tool

A tool (function) definition passed to chat() to enable tool/function calling.

Members

Functions

toJson
JSONValue toJson()

Converts to a JSON object for the Ollama API tools array.

Variables

function_
ToolFunction function_;

The function definition.

type
string type;

Tool type; currently always "function".

Examples

auto schema = parseJSON(`{
    "type": "object",
    "properties": {"location": {"type": "string"}},
    "required": ["location"]
}`);
auto tool = Tool("function", ToolFunction("get_weather", "Get current weather", schema));
auto resp = client.chat("llama3", messages, JSONValue.init, false, [tool]);

Meta