mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 02:34:29 +00:00
Squashed commit of the following: commit6678e15381
Author: Ishaan Jaff <ishaanjaffer0324@gmail.com> Date: Wed Feb 26 09:29:15 2025 -0800 test_prompt_caching commitbd86e0ac47
Author: Ishaan Jaff <ishaanjaffer0324@gmail.com> Date: Wed Feb 26 08:57:16 2025 -0800 test_prompt_caching commit2fc21ad51e
Author: Ishaan Jaff <ishaanjaffer0324@gmail.com> Date: Wed Feb 26 08:13:45 2025 -0800 test_aprompt_caching commitd94cff55ff
Author: Ishaan Jaff <ishaanjaffer0324@gmail.com> Date: Wed Feb 26 08:13:12 2025 -0800 test_prompt_caching commit49c5e7811e
Author: Ishaan Jaff <ishaanjaffer0324@gmail.com> Date: Wed Feb 26 07:43:53 2025 -0800 ui new build commitcb8d5e5917
Author: Ishaan Jaff <ishaanjaffer0324@gmail.com> Date: Wed Feb 26 07:38:56 2025 -0800 (UI) - Create Key flow for existing users (#8844) * working create user button * working create user for a key flow * allow searching users * working create user + key * use clear sections on create key * better search for users * fix create key * ui fix create key button - make it neater / cleaner * ui fix all keys table commit335ba30467
Author: Krrish Dholakia <krrishdholakia@gmail.com> Date: Wed Feb 26 08:53:17 2025 -0800 fix: fix file name commitb8c5b31a4e
Author: Krrish Dholakia <krrishdholakia@gmail.com> Date: Tue Feb 25 22:54:46 2025 -0800 fix: fix utils commitac6e503461
Author: Krrish Dholakia <krrishdholakia@gmail.com> Date: Mon Feb 24 10:43:31 2025 -0800 fix(main.py): fix openai message for assistant msg if role is missing - openai allows this Fixes https://github.com/BerriAI/litellm/issues/8661 commitde3989dbc5
Author: Krrish Dholakia <krrishdholakia@gmail.com> Date: Mon Feb 24 21:19:25 2025 -0800 fix(get_litellm_params.py): handle no-log being passed in via kwargs Fixes https://github.com/BerriAI/litellm/issues/8380
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
import json
|
|
import os
|
|
import sys
|
|
|
|
import pytest
|
|
from fastapi.testclient import TestClient
|
|
|
|
sys.path.insert(
|
|
0, os.path.abspath("../../..")
|
|
) # Adds the parent directory to the system path
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
from litellm import rerank
|
|
from litellm.llms.custom_httpx.http_handler import HTTPHandler
|
|
|
|
|
|
def test_rerank_infer_region_from_model_arn(monkeypatch):
|
|
mock_response = MagicMock()
|
|
|
|
monkeypatch.setenv("AWS_REGION_NAME", "us-east-1")
|
|
args = {
|
|
"model": "bedrock/arn:aws:bedrock:us-west-2::foundation-model/amazon.rerank-v1:0",
|
|
"query": "hello",
|
|
"documents": ["hello", "world"],
|
|
}
|
|
|
|
def return_val():
|
|
return {
|
|
"results": [
|
|
{"index": 0, "relevanceScore": 0.6716859340667725},
|
|
{"index": 1, "relevanceScore": 0.0004994205664843321},
|
|
]
|
|
}
|
|
|
|
mock_response.json = return_val
|
|
mock_response.headers = {"key": "value"}
|
|
mock_response.status_code = 200
|
|
|
|
client = HTTPHandler()
|
|
|
|
with patch.object(client, "post", return_value=mock_response) as mock_post:
|
|
rerank(
|
|
model=args["model"],
|
|
query=args["query"],
|
|
documents=args["documents"],
|
|
client=client,
|
|
)
|
|
mock_post.assert_called_once()
|
|
print(f"mock_post.call_args: {mock_post.call_args.kwargs}")
|
|
assert "us-west-2" in mock_post.call_args.kwargs["url"]
|
|
assert "us-east-1" not in mock_post.call_args.kwargs["url"]
|