pub enum AgentValue {
Unit,
Boolean(bool),
Integer(i64),
Number(f64),
String(Arc<String>),
Image(Arc<PhotonImage>),
Array(Vector<AgentValue>),
Object(HashMap<String, AgentValue>),
Tensor(Arc<Vec<f32>>),
Message(Arc<Message>),
Error(Arc<AgentError>),
}Expand description
The value type passed between agents.
Supports multiple data types with immutable data structures for efficient cloning.
Large data (String, Image, Tensor, etc.) is wrapped in Arc for reference-counted sharing.
Variants§
Unit
Empty value. Used as a trigger signal.
Boolean(bool)
Boolean value.
Integer(i64)
64-bit signed integer.
Number(f64)
64-bit floating point number.
String(Arc<String>)
UTF-8 string wrapped in Arc for efficient cloning.
Image(Arc<PhotonImage>)
Image data (requires image feature).
Array(Vector<AgentValue>)
Ordered array of values.
Object(HashMap<String, AgentValue>)
Key-value map.
Tensor(Arc<Vec<f32>>)
Tensor data for embeddings, etc.
Message(Arc<Message>)
LLM chat message.
Error(Arc<AgentError>)
Error value for propagating errors through the workflow.
Implementations§
Source§impl AgentValue
impl AgentValue
Sourcepub fn image(value: PhotonImage) -> Self
pub fn image(value: PhotonImage) -> Self
Creates an Image value from a PhotonImage.
Sourcepub fn image_arc(value: Arc<PhotonImage>) -> Self
pub fn image_arc(value: Arc<PhotonImage>) -> Self
Creates an Image value from an Arc<PhotonImage>.
Sourcepub fn array(value: Vector<AgentValue>) -> Self
pub fn array(value: Vector<AgentValue>) -> Self
Creates an Array value.
Sourcepub fn object(value: AgentValueMap<String, AgentValue>) -> Self
pub fn object(value: AgentValueMap<String, AgentValue>) -> Self
Creates an Object value.
Sourcepub fn boolean_default() -> Self
pub fn boolean_default() -> Self
Creates a default Boolean value (false).
Sourcepub fn integer_default() -> Self
pub fn integer_default() -> Self
Creates a default Integer value (0).
Sourcepub fn number_default() -> Self
pub fn number_default() -> Self
Creates a default Number value (0.0).
Sourcepub fn string_default() -> Self
pub fn string_default() -> Self
Creates a default String value (empty string).
Sourcepub fn image_default() -> Self
pub fn image_default() -> Self
Creates a default Image value (1x1 transparent pixel).
Sourcepub fn array_default() -> Self
pub fn array_default() -> Self
Creates a default Array value (empty array).
Sourcepub fn object_default() -> Self
pub fn object_default() -> Self
Creates a default Object value (empty object).
Sourcepub fn tensor_default() -> Self
pub fn tensor_default() -> Self
Creates a default Tensor value (empty vector).
Sourcepub fn from_json(value: Value) -> Result<Self, AgentError>
pub fn from_json(value: Value) -> Result<Self, AgentError>
Creates an AgentValue from a serde_json::Value.
§Errors
Returns InvalidValue if the JSON value cannot be converted.
Sourcepub fn from_serialize<T: Serialize>(value: &T) -> Result<Self, AgentError>
pub fn from_serialize<T: Serialize>(value: &T) -> Result<Self, AgentError>
Create AgentValue from Serialize
Sourcepub fn to_deserialize<T: for<'de> Deserialize<'de>>(
&self,
) -> Result<T, AgentError>
pub fn to_deserialize<T: for<'de> Deserialize<'de>>( &self, ) -> Result<T, AgentError>
Convert AgentValue to a Deserialize
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true if this is a Boolean value.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true if this is an Integer value.
Sourcepub fn is_message(&self) -> bool
pub fn is_message(&self) -> bool
Returns true if this is a Message value.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the inner boolean value if this is a Boolean, otherwise None.
Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns the value as i64 if this is an Integer or Number, otherwise None.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns the value as f64 if this is an Integer or Number, otherwise None.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns a reference to the inner string if this is a String, otherwise None.
Sourcepub fn as_image(&self) -> Option<&PhotonImage>
pub fn as_image(&self) -> Option<&PhotonImage>
Returns a reference to the inner image if this is an Image, otherwise None.
Sourcepub fn as_image_mut(&mut self) -> Option<&mut PhotonImage>
pub fn as_image_mut(&mut self) -> Option<&mut PhotonImage>
Returns a mutable reference to the inner image if this is an Image, otherwise None.
Sourcepub fn into_image(self) -> Option<Arc<PhotonImage>>
pub fn into_image(self) -> Option<Arc<PhotonImage>>
Extracts the inner Arc<PhotonImage> if this is an Image, consuming self.
Sourcepub fn as_message(&self) -> Option<&Message>
pub fn as_message(&self) -> Option<&Message>
Returns a reference to the inner message if this is a Message, otherwise None.
Sourcepub fn as_message_mut(&mut self) -> Option<&mut Message>
pub fn as_message_mut(&mut self) -> Option<&mut Message>
Returns a mutable reference to the inner message if this is a Message, otherwise None.
Sourcepub fn into_message(self) -> Option<Arc<Message>>
pub fn into_message(self) -> Option<Arc<Message>>
Extracts the inner Arc<Message> if this is a Message, consuming self.
Sourcepub fn to_boolean(&self) -> Option<bool>
pub fn to_boolean(&self) -> Option<bool>
Converts to a boolean with type coercion.
Conversion rules:
Boolean: returns the valueInteger:0→false, otherwisetrueNumber:0.0→false, otherwisetrueString: parses “true”/“false”
Sourcepub fn to_boolean_value(&self) -> Option<AgentValue>
pub fn to_boolean_value(&self) -> Option<AgentValue>
Converts to AgentValue::Boolean or AgentValue::Array of booleans.
Sourcepub fn to_integer(&self) -> Option<i64>
pub fn to_integer(&self) -> Option<i64>
Converts to an integer (i64) with type coercion.
Sourcepub fn to_integer_value(&self) -> Option<AgentValue>
pub fn to_integer_value(&self) -> Option<AgentValue>
Converts to AgentValue::Integer or AgentValue::Array of integers.
Sourcepub fn to_number_value(&self) -> Option<AgentValue>
pub fn to_number_value(&self) -> Option<AgentValue>
Converts to AgentValue::Number or AgentValue::Array of numbers.
Sourcepub fn to_string_value(&self) -> Option<AgentValue>
pub fn to_string_value(&self) -> Option<AgentValue>
Converts to AgentValue::String or AgentValue::Array of strings.
Sourcepub fn to_message(&self) -> Option<Message>
pub fn to_message(&self) -> Option<Message>
Converts to a Message.
Sourcepub fn to_message_value(&self) -> Option<AgentValue>
pub fn to_message_value(&self) -> Option<AgentValue>
Converts to AgentValue::Message or AgentValue::Array of messages.
If the value is an array, it recursively converts its elements.
Sourcepub fn as_object(&self) -> Option<&AgentValueMap<String, AgentValue>>
pub fn as_object(&self) -> Option<&AgentValueMap<String, AgentValue>>
Returns a reference to the inner object map if this is an Object, otherwise None.
Sourcepub fn as_object_mut(
&mut self,
) -> Option<&mut AgentValueMap<String, AgentValue>>
pub fn as_object_mut( &mut self, ) -> Option<&mut AgentValueMap<String, AgentValue>>
Returns a mutable reference to the inner object map if this is an Object, otherwise None.
Sourcepub fn into_object(self) -> Option<AgentValueMap<String, AgentValue>>
pub fn into_object(self) -> Option<AgentValueMap<String, AgentValue>>
Extracts the inner HashMap if this is an Object, consuming self.
Sourcepub fn as_array(&self) -> Option<&Vector<AgentValue>>
pub fn as_array(&self) -> Option<&Vector<AgentValue>>
Returns a reference to the inner array if this is an Array, otherwise None.
Sourcepub fn as_array_mut(&mut self) -> Option<&mut Vector<AgentValue>>
pub fn as_array_mut(&mut self) -> Option<&mut Vector<AgentValue>>
Returns a mutable reference to the inner array if this is an Array, otherwise None.
Sourcepub fn into_array(self) -> Option<Vector<AgentValue>>
pub fn into_array(self) -> Option<Vector<AgentValue>>
Extracts the inner Vector if this is an Array, consuming self.
Sourcepub fn as_tensor(&self) -> Option<&Vec<f32>>
pub fn as_tensor(&self) -> Option<&Vec<f32>>
Returns a reference to the inner tensor if this is a Tensor, otherwise None.
Sourcepub fn as_tensor_mut(&mut self) -> Option<&mut Vec<f32>>
pub fn as_tensor_mut(&mut self) -> Option<&mut Vec<f32>>
Returns a mutable reference to the inner tensor if this is a Tensor, otherwise None.
Sourcepub fn into_tensor(self) -> Option<Arc<Vec<f32>>>
pub fn into_tensor(self) -> Option<Arc<Vec<f32>>>
Extracts the inner Arc<Vec<f32>> if this is a Tensor, consuming self.
Sourcepub fn into_tensor_vec(self) -> Option<Vec<f32>>
pub fn into_tensor_vec(self) -> Option<Vec<f32>>
Extracts the inner Vec<f32> if this is a Tensor, consuming self.
Possibly O(n) copy.
Sourcepub fn get(&self, key: &str) -> Option<&AgentValue>
pub fn get(&self, key: &str) -> Option<&AgentValue>
Gets a value by key from an Object.
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut AgentValue>
pub fn get_mut(&mut self, key: &str) -> Option<&mut AgentValue>
Gets a mutable reference to a value by key from an Object.
Sourcepub fn get_str(&self, key: &str) -> Option<&str>
pub fn get_str(&self, key: &str) -> Option<&str>
Gets a string reference by key from an Object.
Sourcepub fn get_image(&self, key: &str) -> Option<&PhotonImage>
pub fn get_image(&self, key: &str) -> Option<&PhotonImage>
Gets an image reference by key from an Object.
Sourcepub fn get_image_mut(&mut self, key: &str) -> Option<&mut PhotonImage>
pub fn get_image_mut(&mut self, key: &str) -> Option<&mut PhotonImage>
Gets a mutable image reference by key from an Object.
Sourcepub fn get_object(
&self,
key: &str,
) -> Option<&AgentValueMap<String, AgentValue>>
pub fn get_object( &self, key: &str, ) -> Option<&AgentValueMap<String, AgentValue>>
Gets an object reference by key from an Object.
Sourcepub fn get_object_mut(
&mut self,
key: &str,
) -> Option<&mut AgentValueMap<String, AgentValue>>
pub fn get_object_mut( &mut self, key: &str, ) -> Option<&mut AgentValueMap<String, AgentValue>>
Gets a mutable object reference by key from an Object.
Sourcepub fn get_array(&self, key: &str) -> Option<&Vector<AgentValue>>
pub fn get_array(&self, key: &str) -> Option<&Vector<AgentValue>>
Gets an array reference by key from an Object.
Sourcepub fn get_array_mut(&mut self, key: &str) -> Option<&mut Vector<AgentValue>>
pub fn get_array_mut(&mut self, key: &str) -> Option<&mut Vector<AgentValue>>
Gets a mutable array reference by key from an Object.
Sourcepub fn get_tensor(&self, key: &str) -> Option<&Vec<f32>>
pub fn get_tensor(&self, key: &str) -> Option<&Vec<f32>>
Gets a tensor reference by key from an Object.
Sourcepub fn get_tensor_mut(&mut self, key: &str) -> Option<&mut Vec<f32>>
pub fn get_tensor_mut(&mut self, key: &str) -> Option<&mut Vec<f32>>
Gets a mutable tensor reference by key from an Object.
Sourcepub fn get_message(&self, key: &str) -> Option<&Message>
pub fn get_message(&self, key: &str) -> Option<&Message>
Gets a message reference by key from an Object.
Sourcepub fn get_message_mut(&mut self, key: &str) -> Option<&mut Message>
pub fn get_message_mut(&mut self, key: &str) -> Option<&mut Message>
Gets a mutable message reference by key from an Object.
Sourcepub fn set(&mut self, key: String, value: AgentValue) -> Result<(), AgentError>
pub fn set(&mut self, key: String, value: AgentValue) -> Result<(), AgentError>
Trait Implementations§
Source§impl Clone for AgentValue
impl Clone for AgentValue
Source§fn clone(&self) -> AgentValue
fn clone(&self) -> AgentValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AgentValue
impl Debug for AgentValue
Source§impl Default for AgentValue
impl Default for AgentValue
Source§impl<'de> Deserialize<'de> for AgentValue
impl<'de> Deserialize<'de> for AgentValue
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>,
Source§impl From<&str> for AgentValue
impl From<&str> for AgentValue
Source§impl From<()> for AgentValue
impl From<()> for AgentValue
Source§impl From<AgentError> for AgentValue
impl From<AgentError> for AgentValue
Source§fn from(value: AgentError) -> Self
fn from(value: AgentError) -> Self
Source§impl From<HashMap<String, AgentValue>> for AgentValue
impl From<HashMap<String, AgentValue>> for AgentValue
Source§impl From<HashMap<String, AgentValue>> for AgentValue
impl From<HashMap<String, AgentValue>> for AgentValue
Source§impl From<Message> for AgentValue
impl From<Message> for AgentValue
Source§impl From<Option<AgentValue>> for AgentValue
impl From<Option<AgentValue>> for AgentValue
Source§fn from(value: Option<AgentValue>) -> Self
fn from(value: Option<AgentValue>) -> Self
Source§impl From<String> for AgentValue
impl From<String> for AgentValue
Source§impl From<ToolInfo> for AgentValue
impl From<ToolInfo> for AgentValue
Source§impl From<Vec<AgentValue>> for AgentValue
impl From<Vec<AgentValue>> for AgentValue
Source§fn from(value: Vec<AgentValue>) -> Self
fn from(value: Vec<AgentValue>) -> Self
Source§impl From<Vector<AgentValue>> for AgentValue
impl From<Vector<AgentValue>> for AgentValue
Source§fn from(value: Vector<AgentValue>) -> Self
fn from(value: Vector<AgentValue>) -> Self
Source§impl From<bool> for AgentValue
impl From<bool> for AgentValue
Source§impl From<f32> for AgentValue
impl From<f32> for AgentValue
Source§impl From<f64> for AgentValue
impl From<f64> for AgentValue
Source§impl From<i32> for AgentValue
impl From<i32> for AgentValue
Source§impl From<i64> for AgentValue
impl From<i64> for AgentValue
Source§impl From<u64> for AgentValue
impl From<u64> for AgentValue
Source§impl From<usize> for AgentValue
impl From<usize> for AgentValue
Source§impl PartialEq for AgentValue
impl PartialEq for AgentValue
Source§impl Serialize for AgentValue
impl Serialize for AgentValue
Source§impl TryFrom<AgentValue> for Message
impl TryFrom<AgentValue> for Message
Source§type Error = AgentError
type Error = AgentError
Auto Trait Implementations§
impl Freeze for AgentValue
impl RefUnwindSafe for AgentValue
impl Send for AgentValue
impl Sync for AgentValue
impl Unpin for AgentValue
impl UnsafeUnpin for AgentValue
impl UnwindSafe for AgentValue
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
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, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
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, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more