diff --git a/litellm/passthrough/main.py b/litellm/passthrough/main.py index a3d238e78a3..885b145645c 100644 --- a/litellm/passthrough/main.py +++ b/litellm/passthrough/main.py @@ -384,7 +384,8 @@ def classification_passthrough_request( client=client, timeout=timeout, ) - assert isinstance(response, httpx.Response) + if not isinstance(response, httpx.Response): + raise TypeError(f"Expected httpx.Response from classify passthrough, got {type(response).__name__}") return response @@ -411,7 +412,8 @@ async def aclassification_passthrough_request( client=client, timeout=timeout, ) - assert isinstance(response, httpx.Response) + if not isinstance(response, httpx.Response): + raise TypeError(f"Expected httpx.Response from classify passthrough, got {type(response).__name__}") return response diff --git a/litellm/types/classification.py b/litellm/types/classification.py index f93fb2e1de5..397fa1a0fd9 100644 --- a/litellm/types/classification.py +++ b/litellm/types/classification.py @@ -22,7 +22,7 @@ class ClassificationData(BaseModel): model_config = ConfigDict(extra="allow") index: int - label: str | None + label: str | None = None probs: list[float] num_classes: int diff --git a/tests/test_litellm/passthrough/test_classify.py b/tests/test_litellm/passthrough/test_classify.py index eaebd9efd67..e9798a4053e 100644 --- a/tests/test_litellm/passthrough/test_classify.py +++ b/tests/test_litellm/passthrough/test_classify.py @@ -69,7 +69,13 @@ async def test_aclassify_accepts_token_ids() -> None: "priority": 0, "add_special_tokens": False, } - return httpx.Response(status_code=200, json=CLASSIFICATION_RESPONSE) + return httpx.Response( + status_code=200, + json={ + **CLASSIFICATION_RESPONSE, + "data": [{"index": 0, "probs": [0.1, 0.9], "num_classes": 2}], + }, + ) async with httpx.AsyncClient(transport=httpx.MockTransport(transport)) as async_client: response = await litellm.aclassify( @@ -82,3 +88,4 @@ async def test_aclassify_accepts_token_ids() -> None: assert isinstance(response, ClassificationResponse) assert response.id == "classify-test" + assert response.data[0].label is None