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 for translating 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 and derives the SIM
symbol from the function name. Inbound request JSON cannot set trusted
SIM symbols or required capabilities; those come from the server-owned
runtime registry.
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.
Sourcepub fn request_descriptor_json(&self) -> Value
pub fn request_descriptor_json(&self) -> Value
Renders this tool as an OpenAI request descriptor without SIM authority extension fields.
Use this form when a descriptor may cross an untrusted request boundary:
the gateway resolves the SIM symbol and required capabilities from its
server-owned registry rather than from x-sim-* request fields.
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 more