From 2eb73860951ae07201e14125654bad60aa37873b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 25 Nov 2023 14:25:06 -0800 Subject: [PATCH] fix(utils.py): fix embedding response object conversion --- litellm/tests/test_caching.py | 2 +- litellm/utils.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/litellm/tests/test_caching.py b/litellm/tests/test_caching.py index 69e7deb505..ab24d3e701 100644 --- a/litellm/tests/test_caching.py +++ b/litellm/tests/test_caching.py @@ -90,7 +90,7 @@ def test_embedding_caching(): print(f"embedding2: {embedding2}") pytest.fail("Error occurred: Embedding caching failed") -# test_embedding_caching() +test_embedding_caching() def test_embedding_caching_azure(): diff --git a/litellm/utils.py b/litellm/utils.py index 6e64a3b8a0..689f317266 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -3330,10 +3330,9 @@ def convert_to_model_response_object(response_object: Optional[dict]=None, model index = embedding.get("index", idx), object=embedding.get("object", "embedding") ) - if isinstance(embedding_obj, EmbeddingResponse): - embedding_data.append(embedding_obj) - if len(embedding_data) > 0: - model_response_object.data = embedding_data + embedding_data.append(embedding_obj) + + model_response_object.data = embedding_data if "usage" in response_object and response_object["usage"] is not None: model_response_object.usage.completion_tokens = response_object["usage"].get("completion_tokens", 0) # type: ignore