pub struct ToolSchema {
pub name: String,
pub description: String,
pub parameters: Value,
pub policy: ToolPolicy,
pub metadata: RunMetadata,
}Expand description
The definition of a tool.
The model decides whether to call the tool and how to generate arguments
from name / description / parameters; Provider implementations map
those three fields to the vendor’s wire format. ToolPolicy and
ToolSchema::metadata are framework-facing metadata and are not sent to
providers unless a provider adapter explicitly supports such annotations.
§Example
use molo::tool::ToolSchema;
use serde_json::json;
let schema = ToolSchema::new(
"get_weather",
"Get the weather for a given city",
json!({
"type": "object",
"properties": {
"city": { "type": "string", "description": "City name" }
},
"required": ["city"]
}),
);
assert_eq!(schema.name, "get_weather");Fields§
§name: StringTool name (the basis on which the model selects a tool).
description: StringTool description (the basis on which the model understands the tool’s purpose).
parameters: ValueJSON Schema for the arguments, preferably generated from a serde
struct with schemars::schema_for!.
policy: ToolPolicyFramework-facing policy declaration.
metadata: RunMetadataFramework/application metadata.
Implementations§
Source§impl ToolSchema
impl ToolSchema
Sourcepub fn new(
name: impl Into<String>,
description: impl Into<String>,
parameters: Value,
) -> Self
pub fn new( name: impl Into<String>, description: impl Into<String>, parameters: Value, ) -> Self
Constructs a tool schema with default policy and no metadata.
Sourcepub fn with_policy(self, policy: ToolPolicy) -> Self
pub fn with_policy(self, policy: ToolPolicy) -> Self
Sets framework-facing policy metadata.
Sourcepub fn with_metadata(self, metadata: RunMetadata) -> Self
pub fn with_metadata(self, metadata: RunMetadata) -> Self
Sets framework/application metadata.
Trait Implementations§
Source§impl Clone for ToolSchema
impl Clone for ToolSchema
Source§fn clone(&self) -> ToolSchema
fn clone(&self) -> ToolSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more