mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-16 23:41:43 +00:00
* fix(bedrock/converse): drop toolSpec.strict for Opus 4.7/4.8
Bedrock Converse routes Claude Opus 4.7/4.8 through an Anthropic-compatible
validator that maps toolSpec to the native tool shape and rejects the extra
`strict` key with `tools.N.custom.strict: Extra inputs are not permitted`,
even though Anthropic's native API accepts `strict` as a top-level tool field
for the same models. Sonnet 4.5/4.6 and Opus <=4.6 accept `toolSpec.strict`
unchanged.
The existing gate `get_bedrock_base_model(model).startswith("anthropic")`
(introduced in #29814 to forward `strict` for Claude on Bedrock Converse) is
too broad and regressed Opus 4.7/4.8 callers — see #31582.
Replace the inline check with a small `bedrock_converse_supports_strict_tools`
helper that excludes the Opus 4.7/4.8 family from strict forwarding. All
other Anthropic models on Bedrock keep the existing behavior.
Closes #31582.
* fix(bedrock/converse): move strict-tools regression to a clean test file
The original regression test was added to
test_litellm_core_utils_prompt_templates_factory.py, which has
pre-existing ruff-format violations throughout (multi-line asserts that
fit on one line). The lint workflow runs `ruff format --check` on
changed files only, so touching that file surfaces those pre-existing
violations and fails CI for unrelated reasons.
Move the #31582 regression coverage into a new dedicated test file so
the format check stays green. Also collapses the helper's `not any(...)`
onto a single line to satisfy ruff format.
Covers: #31582
* refactor(bedrock/converse): drive strict-tools gate from model cost map
Replace the hardcoded Opus 4.7/4.8 pattern list with a
bedrock_converse_supports_strict_tools flag on the affected entries in
model_prices_and_context_window.json, resolved via get_model_info with a
local cost map fallback, so future models with the same restriction only
need a JSON update
* chore: revert unrelated credential_migration.py reformat
---------
Co-authored-by: ly-wang19 <ly-wang19@users.noreply.github.com>
(cherry picked from commit
|
||
|---|---|---|
| .. | ||
| audio_utils | ||
| llm_cost_calc | ||
| llm_response_utils | ||
| prompt_templates | ||
| specialty_caches | ||
| tokenizers | ||
| api_route_to_call_types.py | ||
| app_crypto.py | ||
| asyncify.py | ||
| cached_imports.py | ||
| chat_completion_agentic_loop.py | ||
| cli_token_utils.py | ||
| cloud_storage_security.py | ||
| completion_timeout.py | ||
| core_helpers.py | ||
| coroutine_checker.py | ||
| credential_accessor.py | ||
| custom_logger_registry.py | ||
| dd_tracing.py | ||
| default_encoding.py | ||
| dot_notation_indexing.py | ||
| duration_parser.py | ||
| env_utils.py | ||
| exception_mapping_utils.py | ||
| fallback_utils.py | ||
| get_blog_posts.py | ||
| get_litellm_params.py | ||
| get_llm_provider_logic.py | ||
| get_model_cost_map.py | ||
| get_provider_specific_headers.py | ||
| get_supported_openai_params.py | ||
| health_check_helpers.py | ||
| health_check_utils.py | ||
| initialize_dynamic_callback_params.py | ||
| json_validation_rule.py | ||
| litellm_logging.py | ||
| llm_request_utils.py | ||
| logging_callback_manager.py | ||
| logging_utils.py | ||
| logging_worker.py | ||
| mock_functions.py | ||
| model_param_helper.py | ||
| model_response_utils.py | ||
| README.md | ||
| realtime_streaming.py | ||
| reasoning_effort_utils.py | ||
| redact_messages.py | ||
| request_timeout_resolver.py | ||
| response_header_helpers.py | ||
| rules.py | ||
| safe_json_dumps.py | ||
| safe_json_loads.py | ||
| secret_redaction.py | ||
| sensitive_data_masker.py | ||
| streaming_chunk_builder_utils.py | ||
| streaming_handler.py | ||
| thread_pool_executor.py | ||
| token_counter.py | ||
| url_utils.py | ||
Folder Contents
This folder contains general-purpose utilities that are used in multiple places in the codebase.
Core files:
streaming_handler.py: The core streaming logic + streaming related helper utilscore_helpers.py: code used intypes/- e.g.map_finish_reason.exception_mapping_utils.py: utils for mapping exceptions to openai-compatible error types.default_encoding.py: code for loading the default encoding (tiktoken)get_llm_provider_logic.py: code for inferring the LLM provider from a given model name.duration_parser.py: code for parsing durations - e.g. "1d", "1mo", "10s"api_route_to_call_types.py: mapping of API routes to their corresponding CallTypes (e.g.,/chat/completions-> [acompletion, completion])