pub struct ProviderFunctionTool { /* private fields */ }Expand description
Validated client-executed function declaration shown to a model.
This declares a caller-executed function. providers-kit never executes the callback;
the caller supplies correlated FunctionResult values after returned calls.
§Examples
use providers_kit::generation::{ProviderFunctionTool, JsonSchema};
let tool = ProviderFunctionTool::new(
"lookup",
Some("Find a record".into()),
JsonSchema::new(serde_json::json!({"type":"object"}))?,
)?;
assert_eq!(tool.name(), "lookup");
assert_eq!(tool.description(), Some("Find a record"));
assert_eq!(tool.input_schema().schema()["type"], "object");
Implementations§
Source§impl ProviderFunctionTool
impl ProviderFunctionTool
Sourcepub fn new(
name: impl Into<String>,
description: Option<String>,
input_schema: JsonSchema,
) -> Result<Self, KitError>
pub fn new( name: impl Into<String>, description: Option<String>, input_schema: JsonSchema, ) -> Result<Self, KitError>
Creates a function declaration with a stable non-empty name.
§Errors
Returns an input error for an invalid function name or blank description. The input schema has already been validated by JsonSchema::new.
See crate::generation::ProviderFunctionTool for a complete example.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the provider-visible function name.
See crate::generation::ProviderFunctionTool for a complete example.
Sourcepub fn description(&self) -> Option<&str>
pub fn description(&self) -> Option<&str>
Returns the optional model-visible description.
See crate::generation::ProviderFunctionTool for a complete example.
Sourcepub const fn input_schema(&self) -> &JsonSchema
pub const fn input_schema(&self) -> &JsonSchema
Returns the strict argument schema.
See crate::generation::ProviderFunctionTool for a complete example.
Sourcepub fn into_parts(self) -> (String, Option<String>, JsonSchema)
pub fn into_parts(self) -> (String, Option<String>, JsonSchema)
Consumes the declaration into its validated parts.
§Examples
use providers_kit::generation::{ProviderFunctionTool, JsonSchema};
let tool = ProviderFunctionTool::new(
"lookup",
Some("Find a record".into()),
JsonSchema::new(serde_json::json!({"type":"object"}))?,
)?;
let (name, description, schema) = tool.into_parts();
assert_eq!(name, "lookup");
assert_eq!(description.as_deref(), Some("Find a record"));
assert_eq!(schema.schema()["type"], "object");