pub struct ImagePart {
pub name: String,
pub mime: String,
pub url: String,
pub seen: Option<String>,
}Expand description
One picture attached to a message (#346).
The bytes travel in the message as a data: URL, not as a path. A path is a reference the
model resolves with read_file — a tool call the user sees — and a stored session has to be
able to show what was sent without the file still being where it was. The cap and the type
check live where an image enters (attach), because this struct is also what a session reads
back from disk and re-checking every row on every load would be a cost for no gain.
Fields§
§name: StringWhat the user called it, for the transcript and the compaction placeholder. Empty when a picture arrives without a name.
mime: String§url: Stringdata:<mime>;base64,<…> — the wire’s own spelling of a picture, so nothing has to
reassemble it at request time.
seen: Option<String>What a model that can see said about this picture (#346), written once.
Kept beside the picture rather than in the prompt: a session replayed a week later must not pay for the same description again, and the prompt for a past turn must not change under the session that is still talking about it.
Implementations§
Source§impl ImagePart
impl ImagePart
Sourcepub fn from_data_url(name: &str, url: &str) -> Result<Self, String>
pub fn from_data_url(name: &str, url: &str) -> Result<Self, String>
A picture from a data: URL — the wire’s own spelling, and the only one that is a
picture. A path is a reference the agent resolves with read_file (a tool call the user
sees, and a confinement question), and a link is fetch; neither is bytes.
One sentence per refusal, on every surface: two surfaces wording the same refusal
differently is how one bug gets reported twice (#364).
Sourcepub fn bytes(&self) -> Option<Vec<u8>>
pub fn bytes(&self) -> Option<Vec<u8>>
The bytes behind a data: URL, or None when this part is not one.
#499 needs them twice — once to keep the original, once to know how big the copy has to
be — and the URL is the only place they live, so this is the one decoder in the product.
Sourcepub fn with_data(&self, mime: &str, bytes: &[u8]) -> Self
pub fn with_data(&self, mime: &str, bytes: &[u8]) -> Self
This picture, carrying different bytes — what a working copy replaces.
Sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
How many bytes the payload holds, without decoding it.
pub fn new( name: impl Into<String>, mime: impl Into<String>, url: impl Into<String>, ) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ImagePart
impl<'de> Deserialize<'de> for ImagePart
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 ImagePart
impl StructuralPartialEq for ImagePart
Auto Trait Implementations§
impl Forget for ImagePart
impl Freeze for ImagePart
impl Move for ImagePart
impl RefUnwindSafe for ImagePart
impl Send for ImagePartwhere
RawVecInner: Send,
impl Sync for ImagePartwhere
RawVecInner: Sync,
impl Unpin for ImagePart
impl UnsafeUnpin for ImagePart
impl UnwindSafe for ImagePartwhere
RawVecInner: UnwindSafe,
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.