pub struct ObjectJsonSchema {
pub schema_type: String,
pub properties: IndexMap<String, Value>,
pub required: Vec<String>,
pub description: Option<String>,
pub additional_properties: Option<bool>,
pub extra: HashMap<String, Value>,
}Expand description
JSON Schema for an object type (tool parameters).
This represents the parameters that a tool accepts, using JSON Schema format that is understood by language models for function calling.
Fields§
§schema_type: StringThe schema type (always “object” for tool parameters).
properties: IndexMap<String, Value>Property definitions.
required: Vec<String>List of required property names.
description: Option<String>Description of the schema.
additional_properties: Option<bool>Whether additional properties are allowed.
extra: HashMap<String, Value>Extra schema properties.
Implementations§
Source§impl ObjectJsonSchema
impl ObjectJsonSchema
Sourcepub fn new() -> ObjectJsonSchema
pub fn new() -> ObjectJsonSchema
Create a new empty object schema.
Sourcepub fn with_property(
self,
name: &str,
schema: Value,
required: bool,
) -> ObjectJsonSchema
pub fn with_property( self, name: &str, schema: Value, required: bool, ) -> ObjectJsonSchema
Add a property to the schema.
Sourcepub fn add_property(&mut self, name: &str, schema: Value, required: bool)
pub fn add_property(&mut self, name: &str, schema: Value, required: bool)
Add a property without consuming self.
Sourcepub fn with_description(self, desc: &str) -> ObjectJsonSchema
pub fn with_description(self, desc: &str) -> ObjectJsonSchema
Set the description.
Sourcepub fn with_additional_properties(self, allowed: bool) -> ObjectJsonSchema
pub fn with_additional_properties(self, allowed: bool) -> ObjectJsonSchema
Set whether additional properties are allowed.
Sourcepub fn with_extra(self, key: &str, value: Value) -> ObjectJsonSchema
pub fn with_extra(self, key: &str, value: Value) -> ObjectJsonSchema
Add an extra property to the schema.
Sourcepub fn is_required(&self, name: &str) -> bool
pub fn is_required(&self, name: &str) -> bool
Check if a property is required.
Sourcepub fn get_property(&self, name: &str) -> Option<&Value>
pub fn get_property(&self, name: &str) -> Option<&Value>
Get a property schema.
Sourcepub fn property_count(&self) -> usize
pub fn property_count(&self) -> usize
Get the number of properties.
Trait Implementations§
Source§impl Clone for ObjectJsonSchema
impl Clone for ObjectJsonSchema
Source§fn clone(&self) -> ObjectJsonSchema
fn clone(&self) -> ObjectJsonSchema
Returns a duplicate of the value. Read more
1.0.0 · 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 ObjectJsonSchema
impl Debug for ObjectJsonSchema
Source§impl Default for ObjectJsonSchema
impl Default for ObjectJsonSchema
Source§fn default() -> ObjectJsonSchema
fn default() -> ObjectJsonSchema
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ObjectJsonSchema
impl<'de> Deserialize<'de> for ObjectJsonSchema
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ObjectJsonSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ObjectJsonSchema, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for ObjectJsonSchema
impl PartialEq for ObjectJsonSchema
Source§impl Serialize for ObjectJsonSchema
impl Serialize for ObjectJsonSchema
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
Source§impl TryFrom<Value> for ObjectJsonSchema
impl TryFrom<Value> for ObjectJsonSchema
impl StructuralPartialEq for ObjectJsonSchema
Auto Trait Implementations§
impl Freeze for ObjectJsonSchema
impl RefUnwindSafe for ObjectJsonSchema
impl Send for ObjectJsonSchema
impl Sync for ObjectJsonSchema
impl Unpin for ObjectJsonSchema
impl UnwindSafe for ObjectJsonSchema
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