mirror of
https://github.com/BerriAI/litellm.git
synced 2026-08-28 05:25:59 +00:00
refactor(guardrails): drop dead tool extraction and an Any annotation, ratchet lint budgets
This commit is contained in:
parent
3c808f9c8f
commit
28a277e99e
5 changed files with 10 additions and 26 deletions
|
|
@ -3,7 +3,7 @@
|
|||
"limit": 29204
|
||||
},
|
||||
"reportArgumentType": {
|
||||
"limit": 2635
|
||||
"limit": 2634
|
||||
},
|
||||
"reportAssignmentType": {
|
||||
"limit": 329
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
"limit": 19
|
||||
},
|
||||
"reportExplicitAny": {
|
||||
"limit": 9227
|
||||
"limit": 9226
|
||||
},
|
||||
"reportFunctionMemberAccess": {
|
||||
"limit": 7
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
"limit": 113
|
||||
},
|
||||
"reportUnknownMemberType": {
|
||||
"limit": 40340
|
||||
"limit": 40339
|
||||
},
|
||||
"reportUnknownParameterType": {
|
||||
"limit": 20293
|
||||
|
|
@ -117,13 +117,13 @@
|
|||
"limit": 122
|
||||
},
|
||||
"reportUnnecessaryComparison": {
|
||||
"limit": 703
|
||||
"limit": 702
|
||||
},
|
||||
"reportUnnecessaryContains": {
|
||||
"limit": 5
|
||||
},
|
||||
"reportUnnecessaryIsInstance": {
|
||||
"limit": 865
|
||||
"limit": 864
|
||||
},
|
||||
"reportUntypedBaseClass": {
|
||||
"limit": 72
|
||||
|
|
|
|||
|
|
@ -574,22 +574,6 @@ class AnthropicMessagesHandler(BaseTranslation):
|
|||
data: Final = source.get("data")
|
||||
return (data,) if data else ()
|
||||
|
||||
def _extract_input_tools(
|
||||
self,
|
||||
tools: list[dict[str, Any]],
|
||||
tools_to_check: list[ChatCompletionToolParam],
|
||||
) -> None:
|
||||
"""
|
||||
Extract tools from a message.
|
||||
"""
|
||||
## CHECK FOR TOOLS
|
||||
if tools is not None and isinstance(tools, list):
|
||||
# TRANSFORM ANTHROPIC TOOLS TO OPENAI TOOLS
|
||||
openai_tools: Final = self.adapter.translate_anthropic_tools_to_openai(
|
||||
tools=cast(list[AllAnthropicToolsValues], tools)
|
||||
)
|
||||
tools_to_check.extend(openai_tools)
|
||||
|
||||
async def _apply_guardrail_responses_to_input(
|
||||
self,
|
||||
messages: list[dict[str, Any]],
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ def openai_messages_without_tool(
|
|||
return tuple(m for m in messages if _message_role(m) != "tool")
|
||||
|
||||
|
||||
def effective_scan_only_tool_results_for_guardrail(guardrail_to_apply: Any) -> bool:
|
||||
def effective_scan_only_tool_results_for_guardrail(guardrail_to_apply: object) -> bool:
|
||||
return getattr(guardrail_to_apply, "scan_only_tool_results", None) is True
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
"limit": 81
|
||||
},
|
||||
"B010": {
|
||||
"limit": 194
|
||||
"limit": 192
|
||||
},
|
||||
"B018": {
|
||||
"limit": 2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"LIT001": {
|
||||
"limit": 23343
|
||||
"limit": 23337
|
||||
},
|
||||
"LIT002": {
|
||||
"limit": 27213
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
"limit": 0
|
||||
},
|
||||
"LIT006": {
|
||||
"limit": 1093
|
||||
"limit": 1092
|
||||
},
|
||||
"LIT007": {
|
||||
"limit": 0
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
"limit": 0
|
||||
},
|
||||
"LIT010": {
|
||||
"limit": 16802
|
||||
"limit": 16796
|
||||
},
|
||||
"LIT011": {
|
||||
"limit": 5602
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue