pub struct MessageParam {
pub content: Vec<ContentBlockParam>,
pub role: String,
}Fields§
§content: Vec<ContentBlockParam>§role: StringImplementations§
Source§impl MessageParam
impl MessageParam
Sourcepub fn new(content: &Bound<'_, PyAny>, role: String) -> Result<Self, TypeError>
pub fn new(content: &Bound<'_, PyAny>, role: String) -> Result<Self, TypeError>
Create a new MessageParam Will accept either a string, Single type of ContentBlockParam, or a list of varying ContentBlockParams Initial logic determines initial type and processes accordingly If string, wraps in TextBlockParam –> ContentBlockParam If single param, pass to ContentBlockParam directly If list, process each item in list to ContentBlockParam
pub fn __str__(&self) -> String
pub fn model_dump<'py>( &self, py: Python<'py>, ) -> Result<Bound<'py, PyAny>, TypeError>
pub fn text(&self) -> String
Source§impl MessageParam
impl MessageParam
Sourcepub fn to_text_block_param(&self) -> Result<TextBlockParam, TypeError>
pub fn to_text_block_param(&self) -> Result<TextBlockParam, TypeError>
Helper function to create a MessageParam from a single TextBlockParam
Trait Implementations§
Source§impl Clone for MessageParam
impl Clone for MessageParam
Source§fn clone(&self) -> MessageParam
fn clone(&self) -> MessageParam
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MessageParam
impl Debug for MessageParam
Source§impl<'de> Deserialize<'de> for MessageParam
impl<'de> Deserialize<'de> for MessageParam
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<'py> IntoPyObject<'py> for MessageParam
impl<'py> IntoPyObject<'py> for MessageParam
Source§type Target = MessageParam
type Target = MessageParam
Source§type Output = Bound<'py, <MessageParam as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <MessageParam as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl MessageConversion for MessageParam
impl MessageConversion for MessageParam
Source§fn to_anthropic_message(&self) -> Result<Self, TypeError>
fn to_anthropic_message(&self) -> Result<Self, TypeError>
Source§fn to_google_message(&self) -> Result<GeminiContent, TypeError>
fn to_google_message(&self) -> Result<GeminiContent, TypeError>
Source§fn to_openai_message(&self) -> Result<ChatMessage, TypeError>
fn to_openai_message(&self) -> Result<ChatMessage, TypeError>
Source§impl MessageFactory for MessageParam
impl MessageFactory for MessageParam
Source§impl PartialEq for MessageParam
impl PartialEq for MessageParam
Source§impl PromptMessageExt for MessageParam
impl PromptMessageExt for MessageParam
Source§fn bind_mut(&mut self, name: &str, value: &str) -> Result<(), TypeError>
fn bind_mut(&mut self, name: &str, value: &str) -> Result<(), TypeError>
Source§fn bind(&self, name: &str, value: &str) -> Result<Self, TypeError>where
Self: Sized,
fn bind(&self, name: &str, value: &str) -> Result<Self, TypeError>where
Self: Sized,
Source§fn extract_variables(&self) -> Vec<String>
fn extract_variables(&self) -> Vec<String>
fn from_text(content: String, role: &str) -> Result<Self, TypeError>
Source§impl PyClass for MessageParam
impl PyClass for MessageParam
Source§impl PyClassImpl for MessageParam
impl PyClassImpl for MessageParam
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = c"\x00"
const RAW_DOC: &'static CStr = c"\x00"
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<MessageParam>
type ThreadChecker = SendablePyClass<MessageParam>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for MessageParam
impl PyClassNewTextSignature for MessageParam
const TEXT_SIGNATURE: &'static str = "(content, role)"
Source§impl PyMethods<MessageParam> for PyClassImplCollector<MessageParam>
impl PyMethods<MessageParam> for PyClassImplCollector<MessageParam>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for MessageParam
impl PyTypeInfo for MessageParam
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
Source§impl Serialize for MessageParam
impl Serialize for MessageParam
impl DerefToPyAny for MessageParam
impl ExtractPyClassWithClone for MessageParam
impl StructuralPartialEq for MessageParam
Auto Trait Implementations§
impl Freeze for MessageParam
impl RefUnwindSafe for MessageParam
impl Send for MessageParam
impl Sync for MessageParam
impl Unpin for MessageParam
impl UnsafeUnpin for MessageParam
impl UnwindSafe for MessageParam
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<'a, 'py, T> FromPyObject<'a, 'py> for T
impl<'a, 'py, T> FromPyObject<'a, 'py> for T
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<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);