mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
chore(bedrock): fix stale test comment; modernize types and narrow tool_calls for lint
Fix the now-inaccurate comment in test_parallel_function_call_anthropic_error_msg (Bedrock Converse no longer raises; modify_params is forced off as a clean baseline that exercises the Anthropic dummy-tool path). Switch the new helper's annotations to builtin list[...] to satisfy the ruff-strict UP006 ceiling, and bind message.get("tool_calls") to a local so basedpyright narrows the union instead of tripping reportGeneralTypeIssues. Both keep the lint budgets ratcheting down rather than bumping ceilings.
This commit is contained in:
parent
600924af32
commit
edb7ec230e
2 changed files with 8 additions and 6 deletions
|
|
@ -191,7 +191,7 @@ class AmazonConverseConfig(BaseConfig):
|
|||
return messages_copy
|
||||
|
||||
@staticmethod
|
||||
def _has_orphaned_tool_blocks(messages: List[AllMessageValues]) -> bool:
|
||||
def _has_orphaned_tool_blocks(messages: list[AllMessageValues]) -> bool:
|
||||
return any(
|
||||
(m.get("role") == "assistant" and m.get("tool_calls"))
|
||||
or m.get("role") in ("tool", "function")
|
||||
|
|
@ -200,8 +200,8 @@ class AmazonConverseConfig(BaseConfig):
|
|||
|
||||
@staticmethod
|
||||
def _neutralize_orphaned_tool_blocks(
|
||||
messages: List[AllMessageValues], optional_params: dict
|
||||
) -> List[AllMessageValues]:
|
||||
messages: list[AllMessageValues], optional_params: dict
|
||||
) -> list[AllMessageValues]:
|
||||
if optional_params.get(
|
||||
"tools"
|
||||
) or not AmazonConverseConfig._has_orphaned_tool_blocks(messages):
|
||||
|
|
@ -223,9 +223,10 @@ class AmazonConverseConfig(BaseConfig):
|
|||
|
||||
def _rewrite(message: AllMessageValues) -> AllMessageValues:
|
||||
role = message.get("role")
|
||||
if role == "assistant" and message.get("tool_calls"):
|
||||
tool_calls = message.get("tool_calls")
|
||||
if role == "assistant" and tool_calls:
|
||||
base_text = convert_content_list_to_str(message)
|
||||
call_texts = [_tool_call_text(call) for call in message["tool_calls"]]
|
||||
call_texts = [_tool_call_text(call) for call in tool_calls]
|
||||
text = "\n".join(filter(None, [base_text, *call_texts]))
|
||||
return ChatCompletionAssistantMessage(role="assistant", content=text)
|
||||
if role in ("tool", "function"):
|
||||
|
|
|
|||
|
|
@ -348,7 +348,8 @@ def test_parallel_function_call_anthropic_error_msg(
|
|||
|
||||
Reference Issue: https://github.com/BerriAI/litellm/issues/24158, https://github.com/BerriAI/litellm/issues/27138
|
||||
"""
|
||||
# Ensure modify_params is False so Bedrock Converse path still raises.
|
||||
# Force modify_params off as a clean baseline: it exercises the Anthropic
|
||||
# dummy-tool path, which injects regardless of modify_params
|
||||
# (other tests in this file set it to True and don't reset it)
|
||||
original_modify_params = litellm.modify_params
|
||||
litellm.modify_params = False
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue