mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix: address Greptile P2 review (MCP allowlist strip, types, docs)
Made-with: Cursor
This commit is contained in:
parent
f7c24ae395
commit
a33a3d29b3
5 changed files with 27 additions and 17 deletions
|
|
@ -149,7 +149,7 @@ MCP_HEALTH_CHECK_TIMEOUT = float(os.getenv("LITELLM_MCP_HEALTH_CHECK_TIMEOUT", "
|
|||
_MCP_STDIO_EXTRA_COMMANDS = os.getenv("LITELLM_MCP_STDIO_EXTRA_COMMANDS", "")
|
||||
MCP_STDIO_ALLOWED_COMMANDS: frozenset = frozenset(
|
||||
{"npx", "uvx", "python", "python3", "node", "docker", "deno"}
|
||||
| (set(_MCP_STDIO_EXTRA_COMMANDS.split(",")) - {""})
|
||||
| {c.strip() for c in _MCP_STDIO_EXTRA_COMMANDS.split(",") if c.strip()}
|
||||
)
|
||||
|
||||
LITELLM_UI_ALLOW_HEADERS = [
|
||||
|
|
|
|||
|
|
@ -657,9 +657,9 @@ class OpenTelemetry(CustomLogger):
|
|||
|
||||
def _get_dynamic_otel_headers_from_kwargs(self, kwargs) -> Optional[dict]:
|
||||
"""Extract dynamic headers from kwargs if available."""
|
||||
standard_callback_dynamic_params: Optional[
|
||||
StandardCallbackDynamicParams
|
||||
] = kwargs.get("standard_callback_dynamic_params")
|
||||
standard_callback_dynamic_params: Optional[StandardCallbackDynamicParams] = (
|
||||
kwargs.get("standard_callback_dynamic_params")
|
||||
)
|
||||
|
||||
if not standard_callback_dynamic_params:
|
||||
return None
|
||||
|
|
@ -2096,7 +2096,7 @@ class OpenTelemetry(CustomLogger):
|
|||
original_export = exporter.export
|
||||
parent = self
|
||||
|
||||
def _export_with_failure_tracking(self, spans):
|
||||
def _export_with_failure_tracking(_exporter_self, spans):
|
||||
try:
|
||||
result = original_export(spans)
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ def _bedrock_invoke_embedded_region_names() -> frozenset:
|
|||
|
||||
|
||||
def strip_bedrock_routing_prefix(model: str) -> str:
|
||||
"""Strip one LiteLLM routing prefix (bedrock/, converse/, etc.)."""
|
||||
"""Strip all LiteLLM routing prefixes (bedrock/, converse/, invoke/, etc.)."""
|
||||
s = model
|
||||
for prefix in ("bedrock/", "converse/", "invoke/", "openai/", "nova-2/", "nova/"):
|
||||
if s.startswith(prefix):
|
||||
|
|
|
|||
|
|
@ -95,16 +95,18 @@ class ModelInfo(BaseModel):
|
|||
id: Optional[
|
||||
str
|
||||
] # Allow id to be optional on input, but it will always be present as a str in the model instance
|
||||
db_model: bool = False # used for proxy - to separate models which are stored in the db vs. config.
|
||||
db_model: bool = (
|
||||
False # used for proxy - to separate models which are stored in the db vs. config.
|
||||
)
|
||||
updated_at: Optional[datetime.datetime] = None
|
||||
updated_by: Optional[str] = None
|
||||
|
||||
created_at: Optional[datetime.datetime] = None
|
||||
created_by: Optional[str] = None
|
||||
|
||||
base_model: Optional[
|
||||
str
|
||||
] = None # specify if the base model is azure/gpt-3.5-turbo etc for accurate cost tracking
|
||||
base_model: Optional[str] = (
|
||||
None # specify if the base model is azure/gpt-3.5-turbo etc for accurate cost tracking
|
||||
)
|
||||
tier: Optional[Literal["free", "paid"]] = None
|
||||
|
||||
"""
|
||||
|
|
@ -173,12 +175,12 @@ class GenericLiteLLMParams(CredentialLiteLLMParams, CustomPricingLiteLLMParams):
|
|||
custom_llm_provider: Optional[str] = None
|
||||
tpm: Optional[int] = None
|
||||
rpm: Optional[int] = None
|
||||
timeout: Optional[
|
||||
Union[float, str, httpx.Timeout]
|
||||
] = None # if str, pass in as os.environ/
|
||||
stream_timeout: Optional[
|
||||
Union[float, str]
|
||||
] = None # timeout when making stream=True calls, if str, pass in as os.environ/
|
||||
timeout: Optional[Union[float, str, httpx.Timeout]] = (
|
||||
None # if str, pass in as os.environ/
|
||||
)
|
||||
stream_timeout: Optional[Union[float, str]] = (
|
||||
None # timeout when making stream=True calls, if str, pass in as os.environ/
|
||||
)
|
||||
max_retries: Optional[int] = None
|
||||
organization: Optional[str] = None # for openai orgs
|
||||
configurable_clientside_auth_params: CONFIGURABLE_CLIENTSIDE_AUTH_PARAMS = None
|
||||
|
|
@ -342,6 +344,8 @@ class LiteLLMParamsTypedDict(TypedDict, total=False):
|
|||
input_cost_per_second: Optional[float]
|
||||
output_cost_per_second: Optional[float]
|
||||
output_cost_per_second_1080p: Optional[float]
|
||||
output_cost_per_second_720p: Optional[float]
|
||||
output_cost_per_second_4k: Optional[float]
|
||||
num_retries: Optional[int]
|
||||
## MOCK RESPONSES ##
|
||||
mock_response: Optional[Union[str, ModelResponse, Exception]]
|
||||
|
|
|
|||
|
|
@ -234,7 +234,11 @@ class ModelInfoBase(ProviderSpecificModelInfo, total=False):
|
|||
output_cost_per_second: Optional[float] # for OpenAI Speech models
|
||||
output_cost_per_second_1080p: Optional[
|
||||
float
|
||||
] # video_generation tier: key output_cost_per_second_<resolution> (e.g. 1080p, 720p)
|
||||
] # video_generation tier: key output_cost_per_second_<resolution> (e.g. 1080p, 720p, 4k)
|
||||
output_cost_per_second_720p: Optional[
|
||||
float
|
||||
] # video_generation tier: 720p resolution
|
||||
output_cost_per_second_4k: Optional[float] # video_generation tier: 4k resolution
|
||||
ocr_cost_per_page: Optional[float] # for OCR models
|
||||
annotation_cost_per_page: Optional[float] # for OCR models
|
||||
search_context_cost_per_query: Optional[
|
||||
|
|
@ -2966,6 +2970,8 @@ class CustomPricingLiteLLMParams(BaseModel):
|
|||
input_cost_per_second: Optional[float] = None
|
||||
output_cost_per_second: Optional[float] = None
|
||||
output_cost_per_second_1080p: Optional[float] = None
|
||||
output_cost_per_second_720p: Optional[float] = None
|
||||
output_cost_per_second_4k: Optional[float] = None
|
||||
input_cost_per_pixel: Optional[float] = None
|
||||
output_cost_per_pixel: Optional[float] = None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue