mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-28 06:23:07 +00:00
fix(pass_through): stop the URL model parser at the query string so a configured key never lands in a spend row's model
Some checks failed
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
Some checks failed
LiteLLM Rust / rust-lint (push) Has been cancelled
LiteLLM Rust / rust-test (push) Has been cancelled
LiteLLM Rust / rust-wheel (push) Has been cancelled
Terraform Provider / gofmt, vet, build, test (push) Has been cancelled
Terraform Provider / Provider endpoints vs proxy OpenAPI schema (push) Has been cancelled
Terraform Modules / fmt, validate, test (aws) (push) Has been cancelled
Terraform Modules / fmt, validate, test (gcp) (push) Has been cancelled
This commit is contained in:
parent
6d0089441d
commit
0b9fd507d2
3 changed files with 19 additions and 1 deletions
|
|
@ -1226,7 +1226,7 @@ def get_vertex_model_id_from_url(url: str) -> str | None:
|
|||
|
||||
`https://${LOCATION}-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/${LOCATION}/publishers/google/models/${MODEL_ID}:streamGenerateContent`
|
||||
"""
|
||||
match: Final = re.search(r"/models/([^:]+)", url)
|
||||
match: Final = re.search(r"/models/([^:?#]+)", url)
|
||||
return match.group(1) if match else None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1293,6 +1293,9 @@ def test_get_vertex_model_id_from_url():
|
|||
model_id = get_vertex_model_id_from_url(url)
|
||||
assert model_id == "gemini-pro"
|
||||
|
||||
url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro?key=provider-secret#frag"
|
||||
assert get_vertex_model_id_from_url(url) == "gemini-pro"
|
||||
|
||||
# Test with invalid URL
|
||||
url = "https://invalid-url.com"
|
||||
model_id = get_vertex_model_id_from_url(url)
|
||||
|
|
|
|||
|
|
@ -8583,6 +8583,21 @@ async def test_passthrough_mid_stream_drop_logs_model_from_url(
|
|||
({"contents": []}, _VERTEX_FLASH_TARGET, "anthropic", "gemini-3.8-flash", "anthropic"),
|
||||
({"custom_llm_provider": "from-body"}, _VERTEX_FLASH_TARGET, None, "gemini-3.8-flash", "from-body"),
|
||||
({"contents": []}, _GEMINI_FLASH_TARGET, None, "gemini-3.8-flash", "gemini"),
|
||||
(
|
||||
{},
|
||||
"https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash?key=provider-secret",
|
||||
"gemini",
|
||||
"gemini-3.8-flash",
|
||||
"gemini",
|
||||
),
|
||||
(
|
||||
{},
|
||||
"https://us-east5-aiplatform.googleapis.com/v1/projects/p/locations/us-east5"
|
||||
"/publishers/google/models/gemini-3.8-flash?key=provider-secret",
|
||||
None,
|
||||
"gemini-3.8-flash",
|
||||
"vertex_ai",
|
||||
),
|
||||
({}, _VERTEX_CLAUDE_RAW_PREDICT_TARGET, None, "vertex_ai/claude-opus-5", "vertex_ai"),
|
||||
(
|
||||
{},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue