mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
Litellm dev 02 07 2025 p2 (#8377)
* fix(caching_routes.py): mask redis password on `/cache/ping` route * fix(caching_routes.py): fix linting erro * fix(caching_routes.py): fix linting error on caching routes * fix: fix test - ignore mask_dict - has a breakpoint * fix(azure.py): add timeout param + elapsed time in azure timeout error * fix(http_handler.py): add elapsed time to http timeout request makes it easier to debug how long request took before failing
This commit is contained in:
parent
ff2529a994
commit
7363b072c1
7 changed files with 126 additions and 25 deletions
File diff suppressed because one or more lines are too long
|
@ -5,6 +5,12 @@ model_list:
|
|||
- model_name: gpt-4
|
||||
litellm_params:
|
||||
model: gpt-3.5-turbo
|
||||
- model_name: azure-gpt-35-turbo
|
||||
litellm_params:
|
||||
model: azure/chatgpt-v-2
|
||||
api_key: os.environ/AZURE_API_KEY
|
||||
api_base: os.environ/AZURE_API_BASE
|
||||
timeout: 0.000000001
|
||||
- model_name: o3-mini
|
||||
litellm_params:
|
||||
model: o3-mini
|
||||
|
@ -12,7 +18,7 @@ model_list:
|
|||
- model_name: anthropic-claude
|
||||
litellm_params:
|
||||
model: claude-3-5-haiku-20241022
|
||||
mock_response: Hi!
|
||||
timeout: 0.000000001
|
||||
- model_name: groq/*
|
||||
litellm_params:
|
||||
model: groq/*
|
||||
|
@ -28,16 +34,11 @@ model_list:
|
|||
api_key: fake-key
|
||||
api_base: https://exampleopenaiendpoint-production.up.railway.app/
|
||||
|
||||
general_settings:
|
||||
enable_jwt_auth: True
|
||||
litellm_jwtauth:
|
||||
team_id_jwt_field: "client_id"
|
||||
team_id_upsert: true
|
||||
scope_mappings:
|
||||
- scope: litellm.api.consumer
|
||||
models: ["anthropic-claude"]
|
||||
routes: ["/v1/chat/completions"]
|
||||
- scope: litellm.api.gpt_3_5_turbo
|
||||
models: ["gpt-3.5-turbo-testing"]
|
||||
enforce_scope_based_access: true
|
||||
enforce_rbac: true
|
||||
litellm_settings:
|
||||
cache: true
|
||||
|
||||
|
||||
router_settings:
|
||||
redis_host: os.environ/REDIS_HOST
|
||||
redis_password: os.environ/REDIS_PASSWORD
|
||||
redis_port: os.environ/REDIS_PORT
|
|
@ -1,12 +1,15 @@
|
|||
import copy
|
||||
from typing import Any, Dict
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request
|
||||
|
||||
import litellm
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
from litellm.caching.caching import RedisCache
|
||||
from litellm.litellm_core_utils.sensitive_data_masker import SensitiveDataMasker
|
||||
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
|
||||
|
||||
masker = SensitiveDataMasker()
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/cache",
|
||||
tags=["caching"],
|
||||
|
@ -21,27 +24,30 @@ async def cache_ping():
|
|||
"""
|
||||
Endpoint for checking if cache can be pinged
|
||||
"""
|
||||
litellm_cache_params = {}
|
||||
specific_cache_params = {}
|
||||
litellm_cache_params: Dict[str, Any] = {}
|
||||
specific_cache_params: Dict[str, Any] = {}
|
||||
try:
|
||||
|
||||
if litellm.cache is None:
|
||||
raise HTTPException(
|
||||
status_code=503, detail="Cache not initialized. litellm.cache is None"
|
||||
)
|
||||
|
||||
litellm_cache_params = {}
|
||||
specific_cache_params = {}
|
||||
for k, v in vars(litellm.cache).items():
|
||||
try:
|
||||
if k == "cache":
|
||||
continue
|
||||
litellm_cache_params[k] = str(copy.deepcopy(v))
|
||||
litellm_cache_params[k] = v
|
||||
except Exception:
|
||||
litellm_cache_params[k] = "<unable to copy or convert>"
|
||||
for k, v in vars(litellm.cache.cache).items():
|
||||
try:
|
||||
specific_cache_params[k] = str(v)
|
||||
specific_cache_params[k] = v
|
||||
except Exception:
|
||||
specific_cache_params[k] = "<unable to copy or convert>"
|
||||
litellm_cache_params = masker.mask_dict(litellm_cache_params)
|
||||
specific_cache_params = masker.mask_dict(specific_cache_params)
|
||||
if litellm.cache.type == "redis":
|
||||
# ping the redis cache
|
||||
ping_response = await litellm.cache.ping()
|
||||
|
@ -56,6 +62,7 @@ async def cache_ping():
|
|||
messages=[{"role": "user", "content": "test from litellm"}],
|
||||
)
|
||||
verbose_proxy_logger.debug("/cache/ping: done with set_cache()")
|
||||
|
||||
return {
|
||||
"status": "healthy",
|
||||
"cache_type": litellm.cache.type,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue