diff --git a/integration-tests/models/test_idefics2.py b/integration-tests/models/test_idefics2.py index d68664c3..d34cce34 100644 --- a/integration-tests/models/test_idefics2.py +++ b/integration-tests/models/test_idefics2.py @@ -38,27 +38,27 @@ async def test_flash_idefics2_next_simple(flash_idefics2_next, response_snapshot assert response == response_snapshot -# @pytest.mark.asyncio -# @pytest.mark.private -# async def test_flash_idefics2_next_all_params(flash_idefics2_next, response_snapshot): -# response = await flash_idefics2_next.generate( -# "Test request", -# max_new_tokens=10, -# repetition_penalty=1.2, -# return_full_text=True, -# stop_sequences=["test"], -# temperature=0.5, -# top_p=0.9, -# top_k=10, -# truncate=5, -# typical_p=0.9, -# watermark=True, -# decoder_input_details=True, -# seed=0, -# ) -# -# assert response.details.generated_tokens == 10 -# assert response == response_snapshot +@pytest.mark.asyncio +@pytest.mark.private +async def test_flash_idefics2_next_all_params(flash_idefics2_next, response_snapshot): + response = await flash_idefics2_next.generate( + "Test request", + max_new_tokens=10, + repetition_penalty=1.2, + return_full_text=True, + stop_sequences=["test"], + temperature=0.5, + top_p=0.9, + top_k=10, + truncate=5, + typical_p=0.9, + watermark=True, + decoder_input_details=True, + seed=0, + ) + + assert response.details.generated_tokens == 10 + assert response == response_snapshot @pytest.mark.asyncio diff --git a/router/src/validation.rs b/router/src/validation.rs index d3c7163e..be4bef00 100644 --- a/router/src/validation.rs +++ b/router/src/validation.rs @@ -510,21 +510,17 @@ fn fetch_image(input: &str) -> Result<(String, usize, usize), ValidationError> { /// Get input length and optionally truncate it fn prepare_input( mut inputs: String, - truncate: Option, + _truncate: Option, tokenizer: &Tokenizer, config: &Option, ) -> Result<(tokenizers::Encoding, String), ValidationError> { static RE: Lazy = Lazy::new(|| Regex::new(r"!\[\]\([^\)]*\)").unwrap()); - tracing::info!("Truncate {truncate:?}"); let tokenizer_query = match config { Some(Config::LlavaNext(config)) => { let mut modified_inputs = String::with_capacity(inputs.len()); let mut tokenizer_query = String::with_capacity(inputs.len()); let mut start = 0; for chunk in RE.find_iter(&inputs) { - if let Some(truncate) = truncate { - return Err(ValidationError::TruncateImage(truncate)); - } let chunk_start = chunk.start(); let chunk_end = chunk.end(); if chunk_start != start { @@ -549,9 +545,6 @@ fn prepare_input( let mut tokenizer_query = String::with_capacity(inputs.len()); let mut start = 0; for chunk in RE.find_iter(&inputs) { - if let Some(truncate) = truncate { - return Err(ValidationError::TruncateImage(truncate)); - } let chunk_start = chunk.start(); let chunk_end = chunk.end(); if chunk_start != start { @@ -688,10 +681,6 @@ pub enum ValidationError { InvalidImageContent(String), #[error("Could not fetch image: {0}")] FailedFetchImage(#[from] reqwest::Error), - #[error( - "`truncate` cannot be used with VLM and images as it is truncating the image in the middle" - )] - TruncateImage(usize), } #[cfg(test)]