#[non_exhaustive]pub struct ModelLimits {
pub context_tokens: Option<u32>,
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 audio_chunk_seconds: Option<u32>,
pub audio_chunk_tokens: Option<u32>,
pub video_max_seconds: Option<u32>,
pub video_max_bytes: Option<u64>,
pub max_request_bytes: Option<u64>,
}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.context_tokens: Option<u32>The context in tokens the model runs with on this node (per slot: llama.cpp’s
--ctx-size divided by --parallel), not the context it was trained for.
max_images: Option<u32>Most images one request may carry.
image_tokens: Option<u32>Tokens one image costs. With image_patch set, the most one image
costs; 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. 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.
audio_max_seconds: Option<u32>Longest audio input in seconds.
audio_tokens_per_minute: Option<u32>Tokens one minute of audio costs.
audio_chunk_seconds: Option<u32>Audio is encoded in pieces this many seconds long, the last one padded, so a short clip
costs a whole piece (audio_chunk_tokens).
audio_chunk_tokens: Option<u32>Tokens one piece of audio_chunk_seconds costs.
video_max_seconds: Option<u32>Longest video the model takes whole, in seconds (models that read video natively).
video_max_bytes: Option<u64>Largest video the model takes whole, in bytes.
max_request_bytes: Option<u64>Largest request body in bytes the serving side accepts.
Implementations§
Source§impl ModelLimits
impl ModelLimits
pub fn new() -> Self
Sourcepub fn is_unknown(&self) -> bool
pub fn is_unknown(&self) -> bool
Whether no limit is known.
pub fn with_context_tokens(self, tokens: u32) -> Self
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 (or at most that, with with_image_patch).
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
Sourcepub fn with_audio_chunks(self, seconds: u32, tokens: u32) -> Self
pub fn with_audio_chunks(self, seconds: u32, tokens: u32) -> Self
Audio is encoded in seconds-long pieces of tokens each; sets
audio_tokens_per_minute to match.
pub fn with_video_max_seconds(self, seconds: u32) -> Self
pub fn with_video_max_bytes(self, bytes: u64) -> Self
pub fn with_max_request_bytes(self, bytes: u64) -> Self
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, if known: whole pieces when the model encodes
audio in pieces (audio_chunk_seconds), else the per-minute
rate rounded up.
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: less context, fewer images, a smaller edge, shorter audio and video, fewer request bytes, a smaller patch and higher token costs. A field known on one side only keeps that side’s value; a field neither side knows stays absent.