OllamaClient.chat

Engages in a chat interaction using the specified model and message history.

class OllamaClient
@safe
JSONValue
chat
(
string model
,,
JSONValue options = JSONValue.init
,
bool stream = false
,
Tool[] tools = null
,
JSONValue format = JSONValue.init
,
string keepAlive = null
,)

Parameters

model string

Model name.

messages Message[]

Array of Message structs (conversation history).

options JSONValue

Raw JSONValue generation options (backward-compatible).

stream bool

Whether to stream the response (not fully supported).

tools Tool[]

Optional tool definitions for tool/function calling.

format JSONValue

Structured output schema or JSONValue("json").

keepAlive string

How long to keep the model loaded.

opts OllamaOptions

Typed OllamaOptions.

Return Value

Type: JSONValue

A JSONValue with "message", "done", and metadata. When the model calls a tool, response["message"]["tool_calls"] is populated.

Meta