Skip to main content

tool_parameters

Function tool_parameters 

Source
pub fn tool_parameters(schema: Value) -> HashMap<String, Value>
Expand description

Convert a JSON Schema Value into the Tool::parameters map shape expected by the protocol.

Panics if the input is not a JSON object — tool parameter schemas are always top-level objects ({"type": "object", ...}). Pair with schema_for or a serde_json::json!(...) literal.

Use try_tool_parameters when the schema comes from dynamic input and should return a recoverable error instead of panicking.

§Example

use github_copilot_sdk::tool::tool_parameters;
use github_copilot_sdk::Tool;

let mut tool = Tool::default();
tool.name = "ping".to_string();
tool.description = "ping the server".to_string();
tool.parameters = tool_parameters(serde_json::json!({"type": "object"}));