#[non_exhaustive]pub struct MediaLimits {
pub max_images: Option<u32>,
pub image_tokens: Option<u32>,
pub image_patch: Option<u32>,
pub image_edge: Option<u32>,
pub audio_max_seconds: Option<u32>,
pub audio_tokens_per_minute: Option<u32>,
pub max_request_bytes: Option<u64>,
pub video_max_seconds: Option<u32>,
pub video_max_bytes: Option<u64>,
pub video_frames_per_minute: Option<u32>,
}Expand description
Media and request limits for one model. See the module docs.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_images: Option<u32>Most images (image_url parts) one request may carry.
image_tokens: Option<u32>Tokens one image costs. With image_patch set, the most one image
costs (at image_edge); otherwise every image costs this much.
image_patch: Option<u32>For models whose image cost grows with size: the edge in pixels of the square one image
token covers (an image costs ceil(w / patch) * ceil(h / patch) tokens after scaling to
image_edge). Absent: a fixed cost per image.
image_edge: Option<u32>The longest image edge in pixels the model uses; larger images are scaled down to it, so sending more only costs bytes.
audio_max_seconds: Option<u32>Longest audio input (input_audio part) in seconds.
audio_tokens_per_minute: Option<u32>Tokens one minute of audio costs (per minute so fractional per-second rates such as 6.25
stay exact; see audio_tokens_per_second).
max_request_bytes: Option<u64>Largest request body in bytes the serving side accepts (an OpenAI bridge’s
max_request_bytes, for example), so a client sizes frames to fit the bytes as well as
the tokens.
video_max_seconds: Option<u32>Longest video clip (video_url part) in seconds the model takes whole. Since 0.5.10.
video_max_bytes: Option<u64>Largest video clip in bytes (decoded, not base64) the model takes whole. Since 0.5.10.
video_frames_per_minute: Option<u32>Most frames the model reads per minute of a clip sent whole (its backend samples down to
this): per minute so rates below one frame a second, such as 0.5, stay exact, as with
audio_tokens_per_minute. See
video_frame_rate for frames per second. Since 0.5.10.
Implementations§
Source§impl MediaLimits
impl MediaLimits
pub fn new() -> Self
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Whether no limit is known (what is left off the wire).
pub fn with_max_images(self, n: u32) -> Self
Sourcepub fn with_image_tokens(self, tokens: u32) -> Self
pub fn with_image_tokens(self, tokens: u32) -> Self
Every image costs tokens.
Sourcepub fn with_image_patch(self, patch: u32) -> Self
pub fn with_image_patch(self, patch: u32) -> Self
The image cost grows with size: one token per patch x patch pixels.
pub fn with_image_edge(self, pixels: u32) -> Self
pub fn with_audio_max_seconds(self, seconds: u32) -> Self
pub fn with_audio_tokens_per_minute(self, tokens: u32) -> Self
pub fn with_max_request_bytes(self, bytes: u64) -> Self
pub fn with_video_max_seconds(self, seconds: u32) -> Self
pub fn with_video_max_bytes(self, bytes: u64) -> Self
Sourcepub fn with_video_frames_per_minute(self, frames: u32) -> Self
pub fn with_video_frames_per_minute(self, frames: u32) -> Self
The model reads at most frames frames per minute of video (120 for 2 per second).
Sourcepub fn video_frame_rate(&self) -> Option<f64>
pub fn video_frame_rate(&self) -> Option<f64>
video_frames_per_minute per second (the frame rate).
Sourcepub fn video_frames(&self, millis: u64) -> Option<u64>
pub fn video_frames(&self, millis: u64) -> Option<u64>
The most frames the model reads from millis of video sent whole (rounded up), if known.
Sourcepub fn check_video(&self, millis: u64, bytes: u64) -> Result<(), &'static str>
pub fn check_video(&self, millis: u64, bytes: u64) -> Result<(), &'static str>
Whether a clip of millis and bytes (decoded) fits the known video limits: Err names
the first it exceeds (video_max_seconds or video_max_bytes). An unknown limit is not
checked, so callers that need one should look for it first.
Sourcepub fn audio_tokens_per_second(&self) -> Option<f64>
pub fn audio_tokens_per_second(&self) -> Option<f64>
audio_tokens_per_minute per second.
Sourcepub fn image_cost(&self, width: u32, height: u32) -> Option<u32>
pub fn image_cost(&self, width: u32, height: u32) -> Option<u32>
What one width x height image costs in tokens, if known: the fixed cost, or with
image_patch the patches after scaling down to
image_edge, capped at image_tokens.
Sourcepub fn scaled(&self, width: u32, height: u32) -> (u32, u32)
pub fn scaled(&self, width: u32, height: u32) -> (u32, u32)
width x height scaled down (aspect kept) so the longer edge fits
image_edge; unchanged when it fits or no edge is known.
Sourcepub fn audio_cost(&self, millis: u64) -> Option<u64>
pub fn audio_cost(&self, millis: u64) -> Option<u64>
What millis of audio costs in tokens (rounded up), if known.
Sourcepub fn or(self, fallback: Self) -> Self
pub fn or(self, fallback: Self) -> Self
Each field from self when known, else from fallback: operator settings over measured
ones (operator.or(measured)).
Sourcepub fn tightest(self, other: Self) -> Self
pub fn tightest(self, other: Self) -> Self
The stricter of two copies, field by field: fewer images, a smaller edge, shorter audio and video, fewer request and video bytes, a lower frame rate, a smaller patch and higher token costs. A field known on one side only keeps that side’s value, so merging an engine’s limits with a model’s loses nothing; a field neither side knows stays absent.
Trait Implementations§
Source§impl Clone for MediaLimits
impl Clone for MediaLimits
impl Copy for MediaLimits
Source§impl Debug for MediaLimits
impl Debug for MediaLimits
Source§impl Default for MediaLimits
impl Default for MediaLimits
Source§impl<'de> Deserialize<'de> for MediaLimits
impl<'de> Deserialize<'de> for MediaLimits
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 MediaLimits
Source§impl Hash for MediaLimits
impl Hash for MediaLimits
Source§impl PartialEq for MediaLimits
impl PartialEq for MediaLimits
Source§impl Serialize for MediaLimits
impl Serialize for MediaLimits
impl StructuralPartialEq for MediaLimits
Auto Trait Implementations§
impl Forget for MediaLimits
impl Freeze for MediaLimits
impl Move for MediaLimits
impl RefUnwindSafe for MediaLimits
impl Send for MediaLimits
impl Sync for MediaLimits
impl Unpin for MediaLimits
impl UnsafeUnpin for MediaLimits
impl UnwindSafe for MediaLimits
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreimpl<T> Message for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.