This commit is contained in:
prassu017 2026-10-28 15:48:49 -04:00 • committed by GitHub
commit 02546bccaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 0 deletions

View file

@ -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

View file

@ -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 = {

View file

@ -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,