pub struct Part {
pub mime_type: MimeType,
pub body: PartBody,
pub name: Option<String>,
pub deliver: Option<Delivery>,
}Expand description
One typed piece of content.
A region entry, a tool output, a user message, a model reply and a final output are each a list of these. Text is a part like any other; its body is inline because its registry row says it is text, and that is the whole difference.
Fields§
§mime_type: MimeTypeThe part’s type.
body: PartBodyIts bytes, inline or by reference.
name: Option<String>A name: the file it came from, the artifact it is, what @name finds.
deliver: Option<Delivery>How a stored part reaches a model, when the default is not wanted.
Implementations§
Source§impl Part
impl Part
Sourcepub fn inline(mime_type: MimeType, s: impl Into<String>) -> Self
pub fn inline(mime_type: MimeType, s: impl Into<String>) -> Self
An inline part of any text-family type.
Sourcepub fn inline_text(&self) -> Option<&str>
pub fn inline_text(&self) -> Option<&str>
The inline text, if this part carries any.
Sourcepub fn is_named(&self, needle: &str) -> bool
pub fn is_named(&self, needle: &str) -> bool
Whether needle, as a model or a person would type it, names this
stored part: its exact name, the file name of a path-shaped needle
(out/hero.png for hero.png), or at least six characters of its
hash in either case. One rule for every tool that takes a part by
name, so context_export and submit_output cannot disagree about
which part hero means. An inline part is never named.
Sourcepub fn tokens(&self, reg: &MimeRegistry) -> usize
pub fn tokens(&self, reg: &MimeRegistry) -> usize
What this part costs a region.
A stored part is charged its stand-in, not its native token estimate. In a region a stored blob is only a reference plus the short stand-in line that stands for it in the assembled prompt; the native estimate on the blob ref (a per-byte rule over a multi-megabyte model is millions of tokens) is the cost of sending the bytes to a model that can read them, charged at request-build time. Charged here instead, no reasonably sized region could hold real media at all.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Part
impl<'de> Deserialize<'de> for Part
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>,
impl Eq for Part
impl StructuralPartialEq for Part
Auto Trait Implementations§
impl Freeze for Part
impl RefUnwindSafe for Part
impl Send for Part
impl Sync for Part
impl Unpin for Part
impl UnsafeUnpin for Part
impl UnwindSafe for Part
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.