mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
litellm_fix: handle empty dict for web_search_options in Nova grounding (#20159)
The condition `value and isinstance(value, dict)` fails for empty dicts
because `{}` is falsy in Python. Users commonly pass `web_search_options={}`
to enable Nova grounding without specifying additional options.
Changed the condition to `isinstance(value, dict)` which correctly handles
both empty and non-empty dicts.
Fixes failing tests:
- test_bedrock_nova_grounding_async
- test_bedrock_nova_grounding_request_transformation
- test_bedrock_nova_grounding_web_search_options_non_streaming
- test_bedrock_nova_grounding_with_function_tools
This commit is contained in:
parent
d5bc80bca9
commit
1b438144dd
1 changed files with 3 additions and 1 deletions
|
|
@ -805,7 +805,9 @@ class AmazonConverseConfig(BaseConfig):
|
|||
if bedrock_tier in ("default", "flex", "priority"):
|
||||
optional_params["serviceTier"] = {"type": bedrock_tier}
|
||||
|
||||
if param == "web_search_options" and value and isinstance(value, dict):
|
||||
if param == "web_search_options" and isinstance(value, dict):
|
||||
# Note: we use `isinstance(value, dict)` instead of `value and isinstance(value, dict)`
|
||||
# because empty dict {} is falsy but is a valid way to enable Nova grounding
|
||||
grounding_tool = self._map_web_search_options(value, model)
|
||||
if grounding_tool is not None:
|
||||
optional_params = self._add_tools_to_optional_params(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue