mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
style: apply black formatting
This commit is contained in:
parent
5b2b4abb6f
commit
a87329d2a5
2 changed files with 8 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ Semantic MCP Tool Filtering using semantic-router
|
|||
|
||||
Filters MCP tools semantically for /chat/completions and /responses endpoints.
|
||||
"""
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
||||
|
||||
from litellm._logging import verbose_logger
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ Semantic Tool Filter Hook
|
|||
Pre-call hook that filters MCP tools semantically before LLM inference.
|
||||
Reduces context window size and improves tool selection accuracy.
|
||||
"""
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
|
||||
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
|
|
@ -226,10 +227,14 @@ class SemanticToolFilterHook(CustomLogger):
|
|||
# Separate MCP tools (prefixed) from non-MCP tools — only filter
|
||||
# MCP tools, always pass non-MCP tools through untouched.
|
||||
def _tool_name(t):
|
||||
return t.get("name", "") if isinstance(t, dict) else getattr(t, "name", "")
|
||||
return (
|
||||
t.get("name", "") if isinstance(t, dict) else getattr(t, "name", "")
|
||||
)
|
||||
|
||||
mcp_tools = [t for t in tools if is_tool_name_prefixed(_tool_name(t))]
|
||||
non_mcp_tools = [t for t in tools if not is_tool_name_prefixed(_tool_name(t))]
|
||||
non_mcp_tools = [
|
||||
t for t in tools if not is_tool_name_prefixed(_tool_name(t))
|
||||
]
|
||||
|
||||
if not mcp_tools:
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue