Skip to main content

check_embedding_input_size

Function check_embedding_input_size 

Source
pub fn check_embedding_input_size(text: &str) -> Result<(), AppError>
Expand description

Rejects an embedding input that would overflow the model’s token window (GAP-SG-02).

The PRIMARY limit is TOKENS: qwen/qwen3-embedding-8b accepts roughly 32K tokens, so an input above crate::constants::EMBEDDING_REQUEST_MAX_TOKENS is rejected before the HTTP request, using the conservative cl100k_base proxy in crate::tokenizer::count_tokens. The byte cap crate::constants::MAX_MEMORY_BODY_LEN is a SECONDARY, coarser guard kept as a cheap short-circuit so a pathological input is rejected even before tokenisation.

§Errors

Returns AppError::Validation (exit 1, permanent) when either limit is exceeded; the message advises splitting the input into smaller memories.