pub struct Function {
pub name: String,
pub description: Option<String>,
pub parameters: Option<Parameters>,
pub arguments: Option<HashMap<String, Value>>,
pub strict: bool,
}
Expand description
Represents a function that can be called by OpenAI tools.
This structure contains metadata about a function including its name, description, parameters, and whether it should be executed in strict mode.
Fields§
§name: String
The name of the function
description: Option<String>
Optional description of what the function does
parameters: Option<Parameters>
Optional parameters that the function accepts
arguments: Option<HashMap<String, Value>>
Optional arguments passed to the function as key-value pairs
strict: bool
Whether the function should be executed in strict mode
Implementations§
Source§impl Function
impl Function
Sourcepub fn new<T: AsRef<str>, U: AsRef<str>>(
name: T,
description: U,
parameters: Parameters,
strict: bool,
) -> Self
pub fn new<T: AsRef<str>, U: AsRef<str>>( name: T, description: U, parameters: Parameters, strict: bool, ) -> Self
Creates a new Function instance with the specified parameters.
§Arguments
name
- The name of the functiondescription
- A description of what the function doesparameters
- The parameters that the function acceptsstrict
- Whether the function should be executed in strict mode
§Returns
A new Function instance
Sourcepub fn arguments_as_map(&self) -> OpenAIToolResult<HashMap<String, Value>>
pub fn arguments_as_map(&self) -> OpenAIToolResult<HashMap<String, Value>>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Function
Custom deserialization implementation for Function.
impl<'de> Deserialize<'de> for Function
Custom deserialization implementation for Function.
This implementation handles the deserialization of Function from JSON,
parsing arguments as JSON strings and converting parameters from JSON objects.
The name
field is required, while other fields are optional.
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Function
impl RefUnwindSafe for Function
impl Send for Function
impl Sync for Function
impl Unpin for Function
impl UnwindSafe for Function
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.