mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-05 07:37:50 +00:00
Merge 02fd30121a into 7c7304c22b
This commit is contained in:
commit
02546bccaf
3 changed files with 15 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ if TYPE_CHECKING:
|
|||
import httpx
|
||||
from aiohttp import ClientSession
|
||||
from openai import AsyncAzureOpenAI, AsyncOpenAI, AzureOpenAI, OpenAI
|
||||
from opentelemetry.trace import Span
|
||||
|
||||
from litellm.litellm_core_utils.litellm_logging import Logging
|
||||
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler
|
||||
|
|
@ -341,6 +342,7 @@ class CallState:
|
|||
model_alias_map: Mapping[str, str] | None = None
|
||||
data_residency: str | None = None
|
||||
litellm_logging_obj: "Logging | None" = None
|
||||
parent_otel_span: "Span | None" = None
|
||||
preset_cache_key: str | None = None
|
||||
cache_key: str | None = None
|
||||
stream_response: "Mapping[str, ModelResponse] | None" = None
|
||||
|
|
|
|||
|
|
@ -445,6 +445,16 @@ def test_provider_specific_cache_key_ignores_litellm_owned_kwargs(monkeypatch: p
|
|||
assert cache.get_cache_key(**{**request, "top_k": 6}) != base_key
|
||||
|
||||
|
||||
def test_provider_specific_cache_key_ignores_parent_otel_span(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(litellm, "enable_caching_on_provider_specific_optional_params", True)
|
||||
cache: Final = Cache(type=LiteLLMCacheType.LOCAL)
|
||||
request: Final = {"model": "gpt-4.1-mini", "messages": [{"role": "user", "content": "hi"}]}
|
||||
|
||||
assert cache.get_cache_key(**request, parent_otel_span=object()) == cache.get_cache_key(
|
||||
**request, parent_otel_span=object()
|
||||
)
|
||||
|
||||
|
||||
def test_cache_key_tells_apart_requests_that_differ_only_in_continuation_token() -> None:
|
||||
cache: Final = Cache(type=LiteLLMCacheType.LOCAL)
|
||||
request: Final = {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import httpx
|
|||
import pytest
|
||||
from aiohttp import ClientSession
|
||||
from openai import AsyncAzureOpenAI, AsyncOpenAI, AzureOpenAI, OpenAI
|
||||
from opentelemetry.trace import Span
|
||||
from pydantic import BaseModel, ConfigDict, TypeAdapter, ValidationError
|
||||
|
||||
import litellm
|
||||
|
|
@ -249,6 +250,7 @@ INTERNAL_STATE_NAMES: Final = (
|
|||
"model_alias_map",
|
||||
"data_residency",
|
||||
"litellm_logging_obj",
|
||||
"parent_otel_span",
|
||||
"preset_cache_key",
|
||||
"cache_key",
|
||||
"stream_response",
|
||||
|
|
@ -524,6 +526,7 @@ TYPE_HINT_NAMESPACE: Final[Mapping[str, object]] = {
|
|||
"ModelResponse": ModelResponse,
|
||||
"ModelResponseStream": ModelResponseStream,
|
||||
"Logging": Logging,
|
||||
"Span": Span,
|
||||
"SecretFields": SecretFields,
|
||||
"CompactionState": CompactionState,
|
||||
"RouterWeights": RouterWeights,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue