fix(proxy): expose url join helper at module level for websocket route

This commit is contained in:
mateo-berri 2026-08-16 14:29:21 -07:00
parent 81aefe4b3c
commit 4ba9d6b136
2 changed files with 6 additions and 9 deletions

View file

@ -2086,7 +2086,7 @@ class BaseOpenAIPassThroughHandler:
# Construct the full target URL by properly joining the base URL and endpoint path
base_url: Final = httpx.URL(base_target_url)
updated_url: Final = BaseOpenAIPassThroughHandler._join_url_paths(
updated_url: Final = _join_url_paths(
base_url=base_url,
path=encoded_endpoint,
custom_llm_provider=custom_llm_provider,
@ -2145,10 +2145,6 @@ class BaseOpenAIPassThroughHandler:
request=request,
)
@staticmethod
def _join_url_paths(base_url: httpx.URL, path: str, custom_llm_provider: litellm.LlmProviders) -> str:
return _join_url_paths(base_url=base_url, path=path, custom_llm_provider=custom_llm_provider)
@router.api_route(
"/cursor/{endpoint:path}",

View file

@ -19,6 +19,7 @@ import litellm
from litellm.proxy.pass_through_endpoints.llm_passthrough_endpoints import (
BaseOpenAIPassThroughHandler,
RouteChecks,
_join_url_paths,
azure_proxy_route,
bedrock_llm_proxy_route,
create_pass_through_route,
@ -74,7 +75,7 @@ class TestBaseOpenAIPassThroughHandler:
# Test joining base URL with no path and a path
base_url = httpx.URL("https://api.example.com")
path = "/v1/chat/completions"
result = BaseOpenAIPassThroughHandler._join_url_paths(
result = _join_url_paths(
base_url, path, litellm.LlmProviders.OPENAI.value
)
print(f"Base URL with no path: '{base_url}' + '{path}' → '{result}'")
@ -83,7 +84,7 @@ class TestBaseOpenAIPassThroughHandler:
# Test joining base URL with path and another path
base_url = httpx.URL("https://api.example.com/v1")
path = "/chat/completions"
result = BaseOpenAIPassThroughHandler._join_url_paths(
result = _join_url_paths(
base_url, path, litellm.LlmProviders.OPENAI.value
)
print(f"Base URL with path: '{base_url}' + '{path}' → '{result}'")
@ -92,7 +93,7 @@ class TestBaseOpenAIPassThroughHandler:
# Test with path not starting with slash
base_url = httpx.URL("https://api.example.com/v1")
path = "chat/completions"
result = BaseOpenAIPassThroughHandler._join_url_paths(
result = _join_url_paths(
base_url, path, litellm.LlmProviders.OPENAI.value
)
print(f"Path without leading slash: '{base_url}' + '{path}' → '{result}'")
@ -101,7 +102,7 @@ class TestBaseOpenAIPassThroughHandler:
# Test with base URL having trailing slash
base_url = httpx.URL("https://api.example.com/v1/")
path = "/chat/completions"
result = BaseOpenAIPassThroughHandler._join_url_paths(
result = _join_url_paths(
base_url, path, litellm.LlmProviders.OPENAI.value
)
print(f"Base URL with trailing slash: '{base_url}' + '{path}' → '{result}'")