mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
fix(proxy): expose url join helper at module level for websocket route
This commit is contained in:
parent
81aefe4b3c
commit
4ba9d6b136
2 changed files with 6 additions and 9 deletions
|
|
@ -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}",
|
||||
|
|
|
|||
|
|
@ -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}'")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue