pub enum Tools {
Function {
function: Function,
},
Retrieval {
retrieval: Retrieval,
},
WebSearch {
web_search: WebSearch,
},
MCP {
mcp: MCP,
},
}Expand description
External capability attached to a chat request.
Variants cover caller-defined functions, knowledge retrieval, web search, and Model Context Protocol servers.
§Examples
use zai_rs::model::tools::{Function, Tools, WebSearch};
use zai_rs::tool::web_search::SearchEngine;
let function_tool = Tools::Function {
function: Function::new(
"get_weather",
"Get weather data",
serde_json::json!({"type": "object"}),
),
};
let search_tool = Tools::WebSearch {
web_search: WebSearch::new(SearchEngine::SearchPro)
.with_enable(true)
.with_count(10)
};Variants§
Function
Custom function calling tool with parameters.
Allows the AI to invoke user-defined functions with structured arguments. Functions must be pre-defined with JSON schemas for parameter validation.
Retrieval
Knowledge retrieval system access tools.
Provides access to knowledge bases, document collections, or other structured information sources that the AI can query.
WebSearch
Web search capabilities for internet access.
Enables the AI to perform web searches and access current information from the internet. Supports various search engines and configurations.
MCP
A provider-hosted MCP tool attached to a chat request.
This config asks the chat service to connect to an MCP server. It is
distinct from crate::mcp::McpClient, which connects from this SDK.