The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fixed lasso import config, redis cluster hash tags for test keys (#15917)
Shadi8a5ff84e49b0
diff --git a/pyproject.toml b/pyproject.tomlindex d4dd55a7063..ddca2cf1d88 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -164,3 +164,9 @@ version_files = [[tool.mypy]plugins = "pydantic.mypy"++[tool.pytest.ini_options]+asyncio_mode = "auto"+markers = [+ "asyncio: mark test as an asyncio test",+]diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_lasso.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_lasso.pyindex 384501076b5..c63974ac3f2 100644--- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_lasso.py+++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_lasso.py@@ -10,7 +10,7 @@ sys.path.insert(0, os.path.abspath("../.."))import litellmfrom litellm import DualCachefrom litellm.proxy._types import UserAPIKeyAuth-from litellm.proxy.guardrails.guardrail_hooks.lasso import (+from litellm.proxy.guardrails.guardrail_hooks.lasso.lasso import (LassoGuardrail,LassoGuardrailMissingSecrets,LassoGuardrailAPIError,@@ -77,7 +77,7 @@ class TestLassoGuardrail:assert guardrail.lasso_api_key == "test-api-key"assert guardrail.user_id == "test-user"assert guardrail.conversation_id == "test-conversation"- assert guardrail.api_base == "https://server.lasso.security/gateway/v3/classify"+ assert guardrail.api_base == "https://server.lasso.security"@pytest.mark.asyncioasync def test_pre_call_no_violations(self):diff --git a/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py b/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.pyindex a8aae3e1a68..a56dd8632d4 100644--- a/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py+++ b/tests/test_litellm/proxy/hooks/test_parallel_request_limiter_v3.py@@ -1094,9 +1094,13 @@ async def test_async_increment_tokens_with_ttl_preservation():except Exception as e:pytest.skip(f"Redis connection failed: {str(e)}")- # Test keys- test_key_with_ttl = "test_ttl_preservation:with_ttl"- test_key_without_ttl = "test_ttl_preservation:without_ttl"+ # Verify the TTL preservation script is registered+ if parallel_request_handler.token_increment_script is None:+ pytest.skip("Token increment script not available - Redis Lua scripting may not be supported")++ # Test keys - use hash tags to ensure they map to same Redis cluster slot+ test_key_with_ttl = "{test_ttl}:with_ttl"+ test_key_without_ttl = "{test_ttl}:without_ttl"try:# Clean up any existing test keys@@ -1126,12 +1130,15 @@ async def test_async_increment_tokens_with_ttl_preservation():pipeline_operations=pipeline_operations_first)+ # Small delay to ensure Redis has processed the commands+ await asyncio.sleep(0.1)+# Verify keys exist and check initial TTLttl_after_first = await redis_cache.async_get_ttl(test_key_with_ttl)value_after_first_with_ttl = await redis_cache.async_get_cache(test_key_with_ttl)value_after_first_without_ttl = await redis_cache.async_get_cache(test_key_without_ttl)- assert value_after_first_with_ttl == 10.0, "First increment should set value to 10.0"+ assert value_after_first_with_ttl == 10.0, f"First increment should set value to 10.0, got {value_after_first_with_ttl}"assert value_after_first_without_ttl == 5.0, "First increment should set value to 5.0"assert ttl_after_first is not None and ttl_after_first > 0, "Key with TTL should have positive TTL after first increment"assert ttl_after_first <= 60, "TTL should not exceed the set value"@@ -1162,6 +1169,9 @@ async def test_async_increment_tokens_with_ttl_preservation():pipeline_operations=pipeline_operations_second)+ # Small delay to ensure Redis has processed the commands+ await asyncio.sleep(0.1)+# Verify TTL preservation and value updatesttl_after_second = await redis_cache.async_get_ttl(test_key_with_ttl)value_after_second_with_ttl = await redis_cache.async_get_cache(test_key_with_ttl)