mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
test(bedrock): restore invoke stream chunk coverage
This commit is contained in:
parent
113b971330
commit
6803a6ae0e
1 changed files with 30 additions and 0 deletions
|
|
@ -2,15 +2,45 @@ import json
|
|||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(
|
||||
0, os.path.abspath("../../../../../..")
|
||||
) # Adds the parent directory to the system path
|
||||
|
||||
from litellm.llms.bedrock.chat.invoke_transformations.anthropic_claude3_transformation import (
|
||||
AmazonAnthropicClaudeConfig,
|
||||
)
|
||||
from litellm.llms.bedrock.chat.invoke_transformations.base_invoke_transformation import (
|
||||
AmazonInvokeConfig,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"config,model",
|
||||
[
|
||||
(AmazonInvokeConfig, "anthropic.claude-3-sonnet-20240229-v1:0"),
|
||||
(AmazonInvokeConfig, "amazon.titan-text-express-v1"),
|
||||
(AmazonInvokeConfig, "mistral.mistral-7b-instruct-v0:2"),
|
||||
(AmazonAnthropicClaudeConfig, "anthropic.claude-sonnet-4-6"),
|
||||
],
|
||||
)
|
||||
def test_transform_request_drops_stream_chunk_size(config, model):
|
||||
"""stream_chunk_size is a LiteLLM-internal knob for re-chunking the HTTP
|
||||
response stream. Leaking it into the provider request body makes Bedrock
|
||||
reject the whole request: ValidationException 'stream_chunk_size: Extra
|
||||
inputs are not permitted'."""
|
||||
request_body = config().transform_request(
|
||||
model=model,
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
optional_params={"stream": True, "stream_chunk_size": 2048, "max_tokens": 10},
|
||||
litellm_params={},
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert "stream_chunk_size" not in json.dumps(request_body)
|
||||
|
||||
|
||||
def test_transform_request_drops_internal_params():
|
||||
"""LiteLLM-internal MCP params (e.g. skip_mcp_handler) are control flags used
|
||||
inside LiteLLM and are not valid Bedrock inference parameters. Leaking them
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue