mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
add tests to make sure correct vertex ai route is used
This commit is contained in:
parent
69a1c75284
commit
ef8f10527f
1 changed files with 55 additions and 0 deletions
|
@ -1969,3 +1969,58 @@ def test_prompt_factory_nested():
|
|||
assert isinstance(
|
||||
message["parts"][0]["text"], str
|
||||
), "'text' value not a string."
|
||||
|
||||
|
||||
def test_get_token_url():
|
||||
from litellm.llms.vertex_httpx import VertexLLM
|
||||
|
||||
vertex_llm = VertexLLM()
|
||||
vertex_ai_project = "adroit-crow-413218"
|
||||
vertex_ai_location = "us-central1"
|
||||
json_obj = get_vertex_ai_creds_json()
|
||||
vertex_credentials = json.dumps(json_obj)
|
||||
|
||||
should_use_v1beta1_features = vertex_llm.is_using_v1beta1_features(
|
||||
optional_params={"cached_content": "hi"}
|
||||
)
|
||||
|
||||
assert should_use_v1beta1_features is True
|
||||
|
||||
_, url = vertex_llm._get_token_and_url(
|
||||
vertex_project=vertex_ai_project,
|
||||
vertex_location=vertex_ai_location,
|
||||
vertex_credentials=vertex_credentials,
|
||||
gemini_api_key="",
|
||||
custom_llm_provider="vertex_ai_beta",
|
||||
should_use_v1beta1_features=should_use_v1beta1_features,
|
||||
api_base=None,
|
||||
model="",
|
||||
stream=False,
|
||||
)
|
||||
|
||||
print("url=", url)
|
||||
|
||||
assert "/v1beta1/" in url
|
||||
|
||||
should_use_v1beta1_features = vertex_llm.is_using_v1beta1_features(
|
||||
optional_params={"temperature": 0.1}
|
||||
)
|
||||
|
||||
_, url = vertex_llm._get_token_and_url(
|
||||
vertex_project=vertex_ai_project,
|
||||
vertex_location=vertex_ai_location,
|
||||
vertex_credentials=vertex_credentials,
|
||||
gemini_api_key="",
|
||||
custom_llm_provider="vertex_ai_beta",
|
||||
should_use_v1beta1_features=should_use_v1beta1_features,
|
||||
api_base=None,
|
||||
model="",
|
||||
stream=False,
|
||||
)
|
||||
|
||||
print("url for normal request", url)
|
||||
|
||||
assert "v1beta1" not in url
|
||||
assert "/v1/" in url
|
||||
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue