mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-19 00:01:29 +00:00
Merge c1281c840f into 1f8bae7eab
This commit is contained in:
commit
720ee59593
2 changed files with 22 additions and 1 deletions
|
|
@ -8,7 +8,10 @@ from pydantic import TypeAdapter, ValidationError
|
|||
|
||||
import litellm
|
||||
from litellm._logging import verbose_logger
|
||||
from litellm.litellm_core_utils.core_helpers import map_finish_reason
|
||||
from litellm.litellm_core_utils.core_helpers import (
|
||||
filter_internal_params,
|
||||
map_finish_reason,
|
||||
)
|
||||
from litellm.litellm_core_utils.logging_utils import track_llm_api_timing
|
||||
from litellm.litellm_core_utils.prompt_templates.factory import (
|
||||
cohere_message_pt,
|
||||
|
|
@ -195,6 +198,7 @@ class AmazonInvokeConfig(BaseConfig, BaseAWSLLM):
|
|||
)
|
||||
inference_params = copy.deepcopy(optional_params)
|
||||
inference_params = {k: v for k, v in inference_params.items() if k not in self.aws_authentication_params}
|
||||
inference_params = filter_internal_params(inference_params)
|
||||
request_data: dict = {}
|
||||
if provider == "cohere":
|
||||
if model.startswith("cohere.command-r"):
|
||||
|
|
|
|||
|
|
@ -39,6 +39,23 @@ def test_transform_request_drops_stream_chunk_size(config, model):
|
|||
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
|
||||
into the provider request body makes Bedrock reject the request. The Converse
|
||||
path already filters them via filter_internal_params; the invoke path must do
|
||||
the same."""
|
||||
request_body = AmazonInvokeConfig().transform_request(
|
||||
model="mistral.mistral-7b-instruct-v0:2",
|
||||
messages=[{"role": "user", "content": "hi"}],
|
||||
optional_params={"skip_mcp_handler": True, "max_tokens": 10},
|
||||
litellm_params={},
|
||||
headers={},
|
||||
)
|
||||
|
||||
assert "skip_mcp_handler" not in json.dumps(request_body)
|
||||
|
||||
|
||||
def test_validate_environment_maps_guardrail_config_to_invoke_headers():
|
||||
"""The InvokeModel API takes the guardrail identifier/version/trace as
|
||||
X-Amzn-Bedrock-* request headers, unlike Converse which takes them in the
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue