ds_api/raw/request/tool.rs
1use serde::{Deserialize, Serialize};
2
3use super::message::ToolType;
4
5#[derive(Debug, Serialize, Deserialize, Clone)]
6pub struct Tool {
7 /// The tool's type. Currently only `function` is supported.
8 pub r#type: ToolType,
9 pub function: Function,
10}
11
12#[derive(Debug, Serialize, Deserialize, Clone)]
13pub struct Function {
14 /// The name of the function to call. Allowed characters: a-z, A-Z, 0-9, underscore and hyphen.
15 /// Maximum length is 64 characters.
16 pub name: String,
17
18 /// A description of the function's behavior to help the model decide when and how to call it.
19 #[serde(skip_serializing_if = "Option::is_none")]
20 pub description: Option<String>,
21
22 /// The function's input parameters described as a JSON Schema object.
23 /// See the Tool Calls guide for examples and the JSON Schema reference for format details.
24 /// Omitting `parameters` defines a function that takes an empty parameter list.
25 pub parameters: serde_json::Value,
26
27 /// Beta feature: when true, the API will use strict mode for function calls.
28 /// In strict mode, outputs are validated against the function's JSON schema to ensure compliance.
29 /// This is a beta feature; consult the Tool Calls guide for usage details.
30 #[serde(skip_serializing_if = "Option::is_none")]
31 pub strict: Option<bool>,
32}