mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
* docs(exception_mapping.md): add missing exception types Fixes https://github.com/Aider-AI/aider/issues/2120#issuecomment-2438971183 * fix(main.py): register custom model pricing with specific key Ensure custom model pricing is registered to the specific model+provider key combination * test: make testing more robust for custom pricing * fix(redis_cache.py): instrument otel logging for sync redis calls ensures complete coverage for all redis cache calls * refactor: pass parent_otel_span for redis caching calls in router allows for more observability into what calls are causing latency issues * test: update tests with new params * refactor: ensure e2e otel tracing for router * refactor(router.py): add more otel tracing acrosss router catch all latency issues for router requests * fix: fix linting error * fix(router.py): fix linting error * fix: fix test * test: fix tests * fix(dual_cache.py): pass ttl to redis cache * fix: fix param
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
"""
|
|
Base Cache implementation. All cache implementations should inherit from this class.
|
|
|
|
Has 4 methods:
|
|
- set_cache
|
|
- get_cache
|
|
- async_set_cache
|
|
- async_get_cache
|
|
"""
|
|
|
|
from typing import TYPE_CHECKING, Any, Optional
|
|
|
|
if TYPE_CHECKING:
|
|
from opentelemetry.trace import Span as _Span
|
|
|
|
Span = _Span
|
|
else:
|
|
Span = Any
|
|
|
|
|
|
class BaseCache:
|
|
def __init__(self, default_ttl: int = 60):
|
|
self.default_ttl = default_ttl
|
|
|
|
def get_ttl(self, **kwargs) -> Optional[int]:
|
|
if kwargs.get("ttl") is not None:
|
|
return kwargs.get("ttl")
|
|
return self.default_ttl
|
|
|
|
def set_cache(self, key, value, **kwargs):
|
|
raise NotImplementedError
|
|
|
|
async def async_set_cache(self, key, value, **kwargs):
|
|
raise NotImplementedError
|
|
|
|
def get_cache(self, key, **kwargs):
|
|
raise NotImplementedError
|
|
|
|
async def async_get_cache(self, key, **kwargs):
|
|
raise NotImplementedError
|
|
|
|
async def batch_cache_write(self, key, value, **kwargs):
|
|
raise NotImplementedError
|
|
|
|
async def disconnect(self):
|
|
raise NotImplementedError
|