mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
test: cover hidden params accessors across response types
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
2d4cb09271
commit
1a990af652
1 changed files with 55 additions and 2 deletions
|
|
@ -1,9 +1,25 @@
|
|||
import json
|
||||
from typing import Final
|
||||
from typing import Final, Protocol, cast
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
from litellm.litellm_core_utils.hidden_params import HIDDEN_PARAMS_ATTR
|
||||
from litellm.types.agents import (
|
||||
AgentCreateResponse,
|
||||
AgentDeleteResult,
|
||||
AgentListResponse,
|
||||
AgentVersionsResponse,
|
||||
LiteLLMSendMessageResponse,
|
||||
)
|
||||
from litellm.types.containers.main import ContainerFileObject, ContainerObject
|
||||
from litellm.types.google_genai.main import GenerateContentResponse
|
||||
from litellm.types.interactions.generated import (
|
||||
CancelInteractionResult,
|
||||
DeleteInteractionResult,
|
||||
InteractionsAPIResponse,
|
||||
InteractionsAPIStreamingResponse,
|
||||
)
|
||||
from litellm.types.responses.main import DeleteResponseResult
|
||||
from litellm.types.utils import (
|
||||
EmbeddingResponse,
|
||||
HiddenParams,
|
||||
|
|
@ -16,6 +32,14 @@ from litellm.types.utils import (
|
|||
)
|
||||
|
||||
|
||||
class _DictHiddenParamsAccessor(Protocol):
|
||||
@property
|
||||
def hidden_params(self) -> dict[str, object]: ...
|
||||
|
||||
@hidden_params.setter
|
||||
def hidden_params(self, hidden_params: dict[str, object]) -> None: ...
|
||||
|
||||
|
||||
def test_rust_is_a_known_litellm_param():
|
||||
assert "rust" in all_litellm_params
|
||||
|
||||
|
|
@ -47,6 +71,35 @@ def test_hidden_params_public_accessor_preserves_identity_and_instance_isolation
|
|||
assert response.hidden_params is replacement
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"response",
|
||||
(
|
||||
AgentCreateResponse.model_construct(),
|
||||
AgentDeleteResult.model_construct(),
|
||||
AgentListResponse.model_construct(),
|
||||
AgentVersionsResponse.model_construct(),
|
||||
LiteLLMSendMessageResponse.model_construct(),
|
||||
ContainerObject.model_construct(),
|
||||
ContainerFileObject.model_construct(),
|
||||
GenerateContentResponse(),
|
||||
InteractionsAPIResponse.model_construct(),
|
||||
InteractionsAPIStreamingResponse.model_construct(),
|
||||
DeleteInteractionResult.model_construct(),
|
||||
CancelInteractionResult.model_construct(),
|
||||
DeleteResponseResult.model_construct(),
|
||||
),
|
||||
)
|
||||
def test_hidden_params_public_accessor_updates_its_backing_storage(
|
||||
response: _DictHiddenParamsAccessor,
|
||||
) -> None:
|
||||
current: Final = response.hidden_params
|
||||
assert cast(object, getattr(response, HIDDEN_PARAMS_ATTR)) is current
|
||||
|
||||
replacement: Final = {"replacement": "visible"}
|
||||
response.hidden_params = replacement
|
||||
assert cast(object, getattr(response, HIDDEN_PARAMS_ATTR)) is replacement
|
||||
|
||||
|
||||
def test_chat_completion_delta_tool_call():
|
||||
from litellm.types.utils import ChatCompletionDeltaToolCall, Function
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue