mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-12 08:42:18 +00:00
test(count_tokens): check a Converse Bedrock deployment's full count beta set on Mantle and the runtime
Some checks failed
Cost map pins recheck / rerun-cost-map-guard (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
LiteLLM Rust DB / db-queries (push) Has been cancelled
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Some checks failed
Cost map pins recheck / rerun-cost-map-guard (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
LiteLLM Rust DB / db-queries (push) Has been cancelled
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
The Mantle case now sends several caller betas and expects exactly the set a bedrock_mantle deployment's count sends, and the runtime case for a Converse deployment expects the betas invoke inference sends, so a count that drops a kept beta or filters through Converse's config fails
This commit is contained in:
parent
6ccfda3618
commit
80efb123d9
1 changed files with 24 additions and 11 deletions
|
|
@ -771,14 +771,20 @@ async def test_mantle_count_for_a_bedrock_deployment_keeps_and_drops_the_caller_
|
|||
_INTERLEAVED_THINKING: Final = "interleaved-thinking-2025-05-14"
|
||||
_CONTEXT_1M: Final = "context-1m-2025-08-07"
|
||||
_MANTLE_COUNT_MODEL: Final = "bedrock_mantle/anthropic.claude-opus-5-5"
|
||||
_CONVERSE_DEPLOYMENT: Final[Mapping[str, JsonValue]] = {
|
||||
"litellm_params": {**DEPLOYMENT["litellm_params"], "model": "bedrock/converse/us.anthropic.claude-opus-5-5"}
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.usefixtures("local_beta_headers_config", "aws_credentials_in_the_environment")
|
||||
async def test_runtime_count_without_a_deployment_sends_the_caller_betas_invoke_inference_sends() -> None:
|
||||
caller_beta: Final = f"{_INTERLEAVED_THINKING},{_CONTEXT_1M}"
|
||||
@pytest.mark.parametrize("deployment", (None, _CONVERSE_DEPLOYMENT), ids=("no-deployment", "converse-deployment"))
|
||||
async def test_runtime_count_without_a_deployment_or_for_a_converse_one_sends_the_caller_betas_invoke_inference_sends(
|
||||
deployment: Mapping[str, JsonValue] | None,
|
||||
) -> None:
|
||||
caller_beta: Final = f"{_INTERLEAVED_THINKING},{_CONTEXT_1M},{ANTHROPIC_MID_CONVERSATION_TOOL_CHANGES_BETA_HEADER}"
|
||||
sent: Final = await _invoke_inference_betas(caller_beta, {})
|
||||
bedrock: Final = await _count_with_caller_beta("us.anthropic.claude-opus-5-5", caller_beta, None)
|
||||
bedrock: Final = await _count_with_caller_beta("us.anthropic.claude-opus-5-5", caller_beta, deployment)
|
||||
|
||||
assert bedrock.posted_hosts() == (RUNTIME_HOST,)
|
||||
counted: Final = _betas_besides_effort(_invoke_body(bedrock.requests[0]))
|
||||
|
|
@ -912,9 +918,6 @@ async def test_mantle_count_for_a_converse_deployment_sends_the_format_and_betas
|
|||
assert _sent_betas(bedrock.requests[0]) == _sent_betas(inference.requests[0]) != ()
|
||||
|
||||
|
||||
_CONVERSE_DEPLOYMENT: Final = {
|
||||
"litellm_params": {**DEPLOYMENT["litellm_params"], "model": "bedrock/converse/us.anthropic.claude-opus-5-5"}
|
||||
}
|
||||
_SYSTEM_OUTPUT_CONFIG_AFTER_A_USER_TURN: Final[tuple[Mapping[str, JsonValue], ...]] = (
|
||||
{"role": "user", "content": "Hi"},
|
||||
{"role": "system", "content": "Answer briefly", "output_config": _EFFORT["output_config"]},
|
||||
|
|
@ -940,15 +943,25 @@ _SYSTEM_OUTPUT_CONFIG_DIRECTIVE_ONLY: Final[tuple[Mapping[str, JsonValue], ...]]
|
|||
),
|
||||
ids=("tool-input-examples", "system-output-config-after-a-user-turn", "system-output-config-directive-only"),
|
||||
)
|
||||
async def test_mantle_count_for_a_converse_deployment_keeps_the_caller_beta_its_body_fields_need(
|
||||
async def test_mantle_count_for_a_converse_deployment_sends_a_mantle_deployments_betas_with_the_one_its_body_needs(
|
||||
messages: Sequence[Mapping[str, JsonValue]], tools: Sequence[Mapping[str, JsonValue]] | None, caller_beta: str
|
||||
) -> None:
|
||||
bedrock: Final = await _count_with_caller_beta(
|
||||
_MANTLE_COUNT_MODEL, caller_beta, _CONVERSE_DEPLOYMENT, messages=messages, tools=tools
|
||||
caller_betas: Final = f"{caller_beta},{_CONTEXT_1M},{_INTERLEAVED_THINKING}"
|
||||
converse: Final = await _count_with_caller_beta(
|
||||
_MANTLE_COUNT_MODEL, caller_betas, _CONVERSE_DEPLOYMENT, messages=messages, tools=tools
|
||||
)
|
||||
mantle: Final = await _count_with_caller_beta(
|
||||
_MANTLE_COUNT_MODEL,
|
||||
caller_betas,
|
||||
{"litellm_params": {**DEPLOYMENT["litellm_params"], "model": _MANTLE_COUNT_MODEL}},
|
||||
messages=messages,
|
||||
tools=tools,
|
||||
)
|
||||
|
||||
assert bedrock.posted_hosts() == (MANTLE_HOST,)
|
||||
assert caller_beta in _sent_betas(bedrock.requests[0])
|
||||
assert converse.posted_hosts() == mantle.posted_hosts() == (MANTLE_HOST,)
|
||||
counted: Final = _sent_betas(converse.requests[0])
|
||||
assert counted == _sent_betas(mantle.requests[0])
|
||||
assert caller_beta in counted
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue