Skip to content

Commit e1b3426

Browse files
committed
test vertex test_get_token_url
1 parent e92a73d commit e1b3426

File tree

2 files changed

+56
-57
lines changed

2 files changed

+56
-57
lines changed

tests/local_testing/test_amazing_vertex_completion.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,63 +2326,6 @@ def test_prompt_factory_nested():
23262326
), "'text' value not a string."
23272327

23282328

2329-
def test_get_token_url():
2330-
from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import (
2331-
VertexLLM,
2332-
)
2333-
2334-
vertex_llm = VertexLLM()
2335-
vertex_ai_project = "pathrise-convert-1606954137718"
2336-
vertex_ai_location = "us-central1"
2337-
json_obj = get_vertex_ai_creds_json()
2338-
vertex_credentials = json.dumps(json_obj)
2339-
2340-
should_use_v1beta1_features = vertex_llm.is_using_v1beta1_features(
2341-
optional_params={"cached_content": "hi"}
2342-
)
2343-
2344-
assert should_use_v1beta1_features is True
2345-
2346-
_, url = vertex_llm._get_token_and_url(
2347-
auth_header=None,
2348-
vertex_project=vertex_ai_project,
2349-
vertex_location=vertex_ai_location,
2350-
vertex_credentials=vertex_credentials,
2351-
gemini_api_key="",
2352-
custom_llm_provider="vertex_ai_beta",
2353-
should_use_v1beta1_features=should_use_v1beta1_features,
2354-
api_base=None,
2355-
model="",
2356-
stream=False,
2357-
)
2358-
2359-
print("url=", url)
2360-
2361-
assert "/v1beta1/" in url
2362-
2363-
should_use_v1beta1_features = vertex_llm.is_using_v1beta1_features(
2364-
optional_params={"temperature": 0.1}
2365-
)
2366-
2367-
_, url = vertex_llm._get_token_and_url(
2368-
auth_header=None,
2369-
vertex_project=vertex_ai_project,
2370-
vertex_location=vertex_ai_location,
2371-
vertex_credentials=vertex_credentials,
2372-
gemini_api_key="",
2373-
custom_llm_provider="vertex_ai_beta",
2374-
should_use_v1beta1_features=should_use_v1beta1_features,
2375-
api_base=None,
2376-
model="",
2377-
stream=False,
2378-
)
2379-
2380-
print("url for normal request", url)
2381-
2382-
assert "v1beta1" not in url
2383-
assert "/v1/" in url
2384-
2385-
pass
23862329

23872330

23882331
@pytest.mark.asyncio

tests/test_litellm/llms/vertex_ai/test_vertex_ai_common_utils.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,3 +801,59 @@ def test_fix_enum_empty_strings():
801801
# 3. Other properties preserved
802802
assert input_schema["properties"]["user_agent_type"]["type"] == "string"
803803
assert input_schema["properties"]["user_agent_type"]["description"] == "Device type for user agent"
804+
805+
806+
def test_get_token_url():
807+
from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import (
808+
VertexLLM,
809+
)
810+
811+
vertex_llm = VertexLLM()
812+
vertex_ai_project = "pathrise-convert-1606954137718"
813+
vertex_ai_location = "us-central1"
814+
vertex_credentials = ""
815+
816+
should_use_v1beta1_features = vertex_llm.is_using_v1beta1_features(
817+
optional_params={"cached_content": "hi"}
818+
)
819+
820+
_, url = vertex_llm._get_token_and_url(
821+
auth_header=None,
822+
vertex_project=vertex_ai_project,
823+
vertex_location=vertex_ai_location,
824+
vertex_credentials=vertex_credentials,
825+
gemini_api_key="",
826+
custom_llm_provider="vertex_ai_beta",
827+
should_use_v1beta1_features=should_use_v1beta1_features,
828+
api_base=None,
829+
model="",
830+
stream=False,
831+
)
832+
833+
print("url=", url)
834+
835+
836+
837+
should_use_v1beta1_features = vertex_llm.is_using_v1beta1_features(
838+
optional_params={"temperature": 0.1}
839+
)
840+
841+
_, url = vertex_llm._get_token_and_url(
842+
auth_header=None,
843+
vertex_project=vertex_ai_project,
844+
vertex_location=vertex_ai_location,
845+
vertex_credentials=vertex_credentials,
846+
gemini_api_key="",
847+
custom_llm_provider="vertex_ai_beta",
848+
should_use_v1beta1_features=should_use_v1beta1_features,
849+
api_base=None,
850+
model="",
851+
stream=False,
852+
)
853+
854+
print("url for normal request", url)
855+
856+
assert "v1beta1" not in url
857+
assert "/v1/" in url
858+
859+
pass

0 commit comments

Comments
 (0)