Skip to content

Commit

Permalink
test: fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
krrishdholakia committed Jan 21, 2025
1 parent 3086804 commit 120308b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions litellm/llms/huggingface/chat/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ def _transform_input(
embed_url: str,
) -> dict:
data: Dict = {}

## TRANSFORMATION ##
if "sentence-transformers" in model:
if len(input) == 0:
Expand Down
8 changes: 6 additions & 2 deletions tests/local_testing/test_embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,12 +642,16 @@ def tgi_mock_post(*args, **kwargs):
from litellm.llms.custom_httpx.http_handler import AsyncHTTPHandler, HTTPHandler


@pytest.mark.parametrize("sync_mode", [True, False])
@pytest.mark.asyncio
async def test_hf_embedding_sentence_sim(sync_mode):
@patch("litellm.llms.huggingface.chat.handler.async_get_hf_task_embedding_for_model")
@pytest.mark.parametrize("sync_mode", [True, False])
async def test_hf_embedding_sentence_sim(
mock_get_hf_task_embedding_for_model, sync_mode # Add this parameter
):
try:
# huggingface/microsoft/codebert-base
# huggingface/facebook/bart-large
mock_get_hf_task_embedding_for_model.return_value = "sentence-similarity"
if sync_mode is True:
client = HTTPHandler(concurrent_limit=1)
else:
Expand Down

0 comments on commit 120308b

Please sign in to comment.