Chat


Description:

public Chat (Connection connection, string model)

Creates a new Chat instance for sending messages to the chat API.

The constructor initializes basic properties. Most properties should be set after construction, including options, stream, think, tools, and agent.

Example

// Create connection
var connection = new Settings.Connection() {
name = "Local Ollama",
url = "http://127.0.0.1:11434/api"
};

// Create chat with properties set via object initializer
var chat = new Call.Chat(connection, "llama3.2") {
stream = true,
think = true,
agent = agent_handler
};

// Create and assign Options object
chat.options = new Call.Options() {
temperature = 0.7,
top_p = 0.9
};

// Or assign existing Options object
chat.options = existing_options;

// Add tools
foreach (var tool in manager.tools.values) {
chat.add_tool(tool);
}

// Send messages
var response = yield chat.send(messages);

Parameters:

connection

The connection settings for the API endpoint

model

The model name to use for chat

Exceptions:

OllmError.INVALID_ARGUMENT

if model is empty