pub struct ToolDefinition {
pub manifest: ToolManifest,
pub contract: ToolContract,
}Expand description
Static authoring helper for tools.
Composes the runtime ToolManifest and ToolContract projections. Both
are #[serde(flatten)]ed so the serialized JSON shape stays flat (and wire/
persistence compatible); the two structs have disjoint field names.
Fields§
§manifest: ToolManifest§contract: ToolContractImplementations§
Source§impl ToolDefinition
impl ToolDefinition
pub fn raw_with_id( id: impl Into<ToolId>, name: impl Into<String>, description: impl Into<String>, input_schema: Value, output_schema: Value, ) -> ToolDefinition
pub fn raw_named( name: impl Into<String>, description: impl Into<String>, input_schema: Value, output_schema: Value, ) -> ToolDefinition
pub fn typed_with_id<Args, Output>(
id: impl Into<ToolId>,
name: impl Into<String>,
description: impl Into<String>,
) -> ToolDefinitionwhere
Args: JsonSchema,
Output: JsonSchema,
pub fn typed<Args, Output>(
name: impl Into<String>,
description: impl Into<String>,
) -> ToolDefinitionwhere
Args: JsonSchema,
Output: JsonSchema,
pub fn raw( id: impl Into<ToolId>, name: impl Into<String>, description: impl Into<String>, input_schema: Value, output_schema: Value, ) -> ToolDefinition
pub fn with_examples(self, examples: Vec<String>) -> ToolDefinition
pub fn with_availability( self, availability: ToolAvailabilityConfig, ) -> ToolDefinition
pub fn with_activation(self, activation: ToolActivation) -> ToolDefinition
pub fn with_agent_surface( self, agent_surface: ToolAgentSurface, ) -> ToolDefinition
pub fn with_argument_projection( self, argument_projection: ToolArgumentProjectionPolicy, ) -> ToolDefinition
pub fn with_scheduling(self, scheduling: ToolScheduling) -> ToolDefinition
pub fn with_retry_policy(self, retry_policy: ToolRetryPolicy) -> ToolDefinition
pub fn with_output_contract( self, output_contract: ToolOutputContract, ) -> ToolDefinition
pub fn with_input_schema_projection( self, profile: impl Into<String>, schema: Value, ) -> ToolDefinition
pub fn with_output_schema_projection( self, profile: impl Into<String>, schema: Value, ) -> ToolDefinition
pub fn with_output_from_input_schema( self, input_field: impl Into<String>, default_schema: Option<Value>, ) -> ToolDefinition
pub fn default_input_schema() -> Value
Sourcepub fn id(&self) -> &ToolId
pub fn id(&self) -> &ToolId
Tool identity. Read very widely, so exposed as a thin accessor over the
composed ToolManifest.
Sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
Tool description. Read very widely, so exposed as a thin accessor.
pub fn input_signature(&self) -> String
pub fn output_summary(&self) -> String
pub fn signature(&self) -> String
pub fn compact_contract(&self) -> CompactToolContract
pub fn compact_contract_with_example_limit( &self, example_limit: usize, ) -> CompactToolContract
pub fn effective_availability(&self) -> ToolAvailability
pub fn model_tool(&self) -> ModelTool
Sourcepub fn manifest(&self) -> ToolManifest
pub fn manifest(&self) -> ToolManifest
Project the manifest, computing the catalog-facing compact contract from
the resolved ToolContract.
pub fn contract(&self) -> ToolContract
Sourcepub fn from_parts(
manifest: ToolManifest,
contract: ToolContract,
) -> ToolDefinition
pub fn from_parts( manifest: ToolManifest, contract: ToolContract, ) -> ToolDefinition
Recompose a definition from its ToolManifest and ToolContract
projections — the inverse of ToolDefinition::manifest/ToolDefinition::contract.
pub fn format_tool_docs(tools: &[ToolDefinition]) -> String
pub fn format_tool_docs_iter<'a>( tools: impl IntoIterator<Item = &'a ToolDefinition>, ) -> String
pub fn parameter_metadata(&self) -> Vec<Value>
Trait Implementations§
Source§impl Clone for ToolDefinition
impl Clone for ToolDefinition
Source§fn clone(&self) -> ToolDefinition
fn clone(&self) -> ToolDefinition
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ToolDefinition
impl Debug for ToolDefinition
Source§impl<'de> Deserialize<'de> for ToolDefinition
impl<'de> Deserialize<'de> for ToolDefinition
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolDefinition, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ToolDefinition, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ToolDefinition
impl Serialize for ToolDefinition
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for ToolDefinition
impl RefUnwindSafe for ToolDefinition
impl Send for ToolDefinition
impl Sync for ToolDefinition
impl Unpin for ToolDefinition
impl UnsafeUnpin for ToolDefinition
impl UnwindSafe for ToolDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more