pub struct OpenAiTool { /* private fields */ }Expand description
A single OpenAI function tool bound to a SIM callable.
Holds the OpenAI-facing function name and JSON Schema parameters
alongside the resolved SIM symbol, argument order, required
capabilities, and optional argument/result shapes used to translate
between OpenAI tool descriptors and SIM calls.
Implementations§
Source§impl OpenAiTool
impl OpenAiTool
Sourcepub fn from_callable(
cx: &mut Cx,
openai_name: impl Into<String>,
symbol: Symbol,
description: impl Into<String>,
parameters: Value,
capabilities: Vec<CapabilityName>,
) -> Result<Self>
pub fn from_callable( cx: &mut Cx, openai_name: impl Into<String>, symbol: Symbol, description: impl Into<String>, parameters: Value, capabilities: Vec<CapabilityName>, ) -> Result<Self>
Builds a tool from a resolved SIM callable, capturing its argument and result shapes from the callable’s browse metadata.
Sourcepub fn from_openai_descriptor(value: &Value) -> Result<Self>
pub fn from_openai_descriptor(value: &Value) -> Result<Self>
Parses an OpenAI tool descriptor JSON object into an OpenAiTool.
Requires the descriptor type to be function, derives the SIM
symbol from an x-sim-symbol hint or from the function name, and reads
optional x-sim-capabilities.
Sourcepub fn openai_name(&self) -> &str
pub fn openai_name(&self) -> &str
Returns the OpenAI-facing tool name.
Sourcepub fn capabilities(&self) -> &[CapabilityName]
pub fn capabilities(&self) -> &[CapabilityName]
Returns the capabilities required to invoke this tool.
Sourcepub fn validate_arguments(&self, arguments: &Value) -> Result<(), String>
pub fn validate_arguments(&self, arguments: &Value) -> Result<(), String>
Validates arguments against the tool’s JSON Schema parameters.
Sourcepub fn argument_values(
&self,
cx: &mut Cx,
arguments: &Value,
) -> Result<Vec<Value>, String>
pub fn argument_values( &self, cx: &mut Cx, arguments: &Value, ) -> Result<Vec<Value>, String>
Validates and converts JSON arguments into ordered SIM values for the call.
Sourcepub fn descriptor_json(&self) -> Value
pub fn descriptor_json(&self) -> Value
Renders this tool as an OpenAI tool descriptor JSON object, including
the x-sim-* extension fields for symbol, shapes, and capabilities.
Trait Implementations§
Source§impl Clone for OpenAiTool
impl Clone for OpenAiTool
Source§fn clone(&self) -> OpenAiTool
fn clone(&self) -> OpenAiTool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OpenAiTool
impl Debug for OpenAiTool
Source§impl PartialEq for OpenAiTool
impl PartialEq for OpenAiTool
Source§fn eq(&self, other: &OpenAiTool) -> bool
fn eq(&self, other: &OpenAiTool) -> bool
self and other values to be equal, and is used by ==.