mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-27 11:43:54 +00:00
test is open ai routes function
This commit is contained in:
parent
b30fa64e2a
commit
d2f8269674
1 changed files with 43 additions and 0 deletions
|
@ -19,6 +19,7 @@ import pytest
|
||||||
|
|
||||||
import litellm
|
import litellm
|
||||||
from litellm.proxy._types import LiteLLMRoutes
|
from litellm.proxy._types import LiteLLMRoutes
|
||||||
|
from litellm.proxy.auth.auth_utils import is_openai_route
|
||||||
from litellm.proxy.proxy_server import router
|
from litellm.proxy.proxy_server import router
|
||||||
|
|
||||||
# Configure logging
|
# Configure logging
|
||||||
|
@ -50,3 +51,45 @@ def test_routes_on_litellm_proxy():
|
||||||
|
|
||||||
for route in LiteLLMRoutes.openai_routes.value:
|
for route in LiteLLMRoutes.openai_routes.value:
|
||||||
assert route in _all_routes
|
assert route in _all_routes
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"route,expected",
|
||||||
|
[
|
||||||
|
# Test exact matches
|
||||||
|
("/chat/completions", True),
|
||||||
|
("/v1/chat/completions", True),
|
||||||
|
("/embeddings", True),
|
||||||
|
("/v1/models", True),
|
||||||
|
("/utils/token_counter", True),
|
||||||
|
# Test routes with placeholders
|
||||||
|
("/engines/gpt-4/chat/completions", True),
|
||||||
|
("/openai/deployments/gpt-3.5-turbo/chat/completions", True),
|
||||||
|
("/threads/thread_49EIN5QF32s4mH20M7GFKdlZ", True),
|
||||||
|
("/v1/threads/thread_49EIN5QF32s4mH20M7GFKdlZ", True),
|
||||||
|
("/threads/thread_49EIN5QF32s4mH20M7GFKdlZ/messages", True),
|
||||||
|
("/v1/threads/thread_49EIN5QF32s4mH20M7GFKdlZ/runs", True),
|
||||||
|
("/v1/batches123456", True),
|
||||||
|
# Test non-OpenAI routes
|
||||||
|
("/some/random/route", False),
|
||||||
|
("/v2/chat/completions", False),
|
||||||
|
("/threads/invalid/format", False),
|
||||||
|
("/v1/non_existent_endpoint", False),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_is_openai_route(route: str, expected: bool):
|
||||||
|
assert is_openai_route(route) == expected
|
||||||
|
|
||||||
|
|
||||||
|
# Test case for routes that are similar but should return False
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"route",
|
||||||
|
[
|
||||||
|
"/v1/threads/thread_id/invalid",
|
||||||
|
"/threads/thread_id/invalid",
|
||||||
|
"/v1/batches/123/invalid",
|
||||||
|
"/engines/model/invalid/completions",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_is_openai_route_similar_but_false(route: str):
|
||||||
|
assert is_openai_route(route) == False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue